text stringlengths 14 6.51M |
|---|
{
gui -- gui of calculator program
version 1.0, August 4th, 2012
Copyright (C) 2012 Florea Marius Florin
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Florea Marius Florin, florea.fmf@gmail.com
}
(* The unit that handles the program gui,
* creates the window, takes input, shows output... *)
{$calling cdecl}
{$mode objfpc}
{$h+}
unit gui;
interface
(* takes care of almost everything in the program.
* from preparing it to responding to user events *)
procedure start();
implementation
uses
glib2, gdk2, gtk2, pango, data, xpm;
type
pGdkPixbuf = pointer;
var
entryBasic, entryAdv, basicWindow, advancedWindow,
menuBasic, menuAdvanced,
(* menu vars, need it when switching modes,
* so the program displays the right mode as selected *)
mbbasic, maadv,
(* spin button for decimal places *)
spinBtn: pGtkWidget;
(* list: display the items in memory *)
list: pGtkWidget;
(* 1st element = the button
* 2nd element = the label of the button *)
listItems: array[1..8,1..2] of pGtkWidget;
(* first element = position (eg: 1, 5, 7);
* 2nd element = actual value of that row (eg: 65, 2*4...); *)
listValues: array[1..8,1..2] of string;
(* the position of the item selected by the user *)
listSelected: integer;
(* 1: visible
* 2: hidden *)
memoryStatus: byte;
(* memory addition, for basic calc *)
madd: string;
(* the last infix string sent for evaluation
* when the user presses return after the string
* has been evaluated, original string will be shown *)
infixStr: string;
(* holds the result of the last infix string evaluation *)
evalStr: string;
(* tels if the user clicked inside the entry *)
clicked: boolean;
progIcon: pGdkPixbuf;
(* *drum rolls* the input string *ta da* *)
input: string;
(* define gtk missing funcs *)
{$ifdef unix}
function gdk_pixbuf_new_from_xpm_data(data: ppgchar): pGdkPixbuf; external 'libgdk_pixbuf-2.0.so';
{$endif}
{$ifdef windows}
function gdk_pixbuf_new_from_xpm_data(data: ppgchar): pGdkPixbuf; external 'libgdk_pixbuf-2.0-0.dll';
{$endif}
(* sets program defaults *)
procedure set_defaults();
begin
MODE:= 1; // basic
EVAL:= 1; // infix
DECIMAL_PLACES:= 2;
memoryStatus:= 2; // hidden
listSelected:= 0;
clicked:= false;
progIcon:= gdk_pixbuf_new_from_xpm_data(ppgchar(XPM_PROG_ICON));
end;
(* used to close the license, credits, decimal, error windows *)
procedure destroy_child_window(qbutton: pGtkButton; window: pGtkWindow);
begin
gtk_widget_destroy(pGtkWidget(window));
end;
(* show hide the memory items *)
procedure memory_show_hide(x: byte);
begin
if (x = 1) then begin
gtk_widget_show_all(list);
memoryStatus:= 1;
end else begin
gtk_widget_hide(list);
memoryStatus:= 2;
end;
end;
(* change program mode
* 1: basic; 2: advanced; *)
procedure switch_mode(widget: pGtkWidget; data: pgpointer);
begin
if (pchar(data) = '1') then begin
gtk_widget_hide(advancedWindow);
gtk_widget_show_all(basicWindow);
gtk_check_menu_item_set_active(pGtkCheckMenuItem(mbbasic), true);
MODE:= 1;
clicked:= false;
end else begin
gtk_widget_hide(basicWindow);
gtk_widget_show_all(advancedWindow);
memory_show_hide(memoryStatus);
gtk_check_menu_item_set_active(pGtkCheckMenuItem(maadv), true);
MODE:= 2;
clicked:= false;
end;
end;
(* change program evaluation method
* 1: infix; 2: postifx *)
procedure switch_eval(widget: pGtkWidget; data: pgpointer);
begin
if (pchar(data) = '1') then begin
EVAL:= 1;
clicked:= false;
end else begin
EVAL:= 2;
clicked:= false;
end;
end;
procedure show_license();
var
window, vbox, button, label_, hbox: pGtkWidget;
begin
window:= gtk_window_new(gtk_window_toplevel);
gtk_window_set_title(pGtkWindow(window), 'License');
gtk_window_set_position(pGtkWindow(window), gtk_win_pos_center_on_parent);
gtk_window_set_destroy_with_parent(pGtkWindow(window), true);
gtk_window_set_resizable(pGtkWindow(window), false);
if (MODE = 1) then
gtk_window_set_transient_for(pGtkWindow(window), pGtkWindow(basicWindow))
else
gtk_window_set_transient_for(pGtkWindow(window), pGtkWindow(advancedWindow));
g_signal_connect(window, 'destroy', g_callback(@gtk_widget_destroy), window);
gtk_widget_realize(window);
vbox:= gtk_vbox_new(false, 0);
gtk_container_add(pGtkContainer(window), vbox);
label_:= gtk_label_new('Calculator -- a calculator program '#10'version 1.0, '+
'August 4, 2012'#10#10'Copyright (C) 2012 Florea Marius Florin'#10#10'This software is '+
'provided ''as-is'', without any express or implied'#10'warranty. In no event will the '+
'authors be held liable for any damages'#10' arising from the use of this software.'+
''#10#10'Permission is granted to anyone to use this software for any purpose,'#10''+
'including commercial applications, and to alter it and redistribute it'#10'freely, '+
'subject to the following restrictions:'#10#10#9'1. The origin of this software must '+
'not be misrepresented; you must not'#10#9#9'claim that you wrote the original software. '+
'If you use this software'#10#9#9'in a product, an acknowledgment in the product '+
'documentation would be'#10#9#9'appreciated but is not required.'#10#9'2. Altered '+
'source versions must be plainly marked as such, and must not be'#10#9#9'misrepresented '+
'as being the original software.'#10#9'3. This notice may not be removed or altered '+
'from any source distribution.'#10#10'Florea Marius Florin, florea.fmf@gmail.com');
gtk_box_pack_start(pGtkBox(vbox), label_, false, false, 0);
hbox:= gtk_hbox_new(false, 0);
gtk_box_pack_start(pGtkBox(vbox), hbox, false, false, 0);
button:= gtk_button_new_with_label(' Close ');
g_signal_connect(g_object(button), 'clicked', g_callback(@destroy_child_window),
pgpointer(window));
gtk_box_pack_end(pGtkBox(hbox), button, false, false, 0);
gtk_widget_show_all(window);
end;
procedure show_credits();
var
window, vbox, hbox, button, label_, img: pGtkWidget;
pixbuf: pGdkPixbuf;
begin
window:= gtk_window_new(gtk_window_toplevel);
gtk_window_set_title(pGtkWindow(window), 'Credits');
gtk_window_set_position(pGtkWindow(window), gtk_win_pos_center_on_parent);
gtk_window_set_destroy_with_parent(pGtkWindow(window), true);
gtk_window_set_resizable(pGtkWindow(window), false);
if (MODE = 1) then
gtk_window_set_transient_for(pGtkWindow(window), pGtkWindow(basicWindow))
else
gtk_window_set_transient_for(pGtkWindow(window), pGtkWindow(advancedWindow));
g_signal_connect(window, 'destroy', g_callback(@gtk_widget_destroy), window);
gtk_widget_realize(window);
vbox:= gtk_vbox_new(false, 0);
gtk_container_add(pGtkContainer(window), vbox);
hbox:= gtk_hbox_new(false, 0);
gtk_box_pack_start(pGtkBox(vbox), hbox, false, false, 0);
label_:= gtk_label_new(#9'Developer: Florea Marius Florin'#10#10#9'Special thanks to:'+
''#10#9#9'-FPC team: for building the compiler'#10#9#9'-Gtk+ team: for making the toolkit');
gtk_box_pack_start(pGtkBox(hbox), label_, false, false, 0);
pixbuf:= gdk_pixbuf_new_from_xpm_data(XPM_BADGER);
img:= gtk_image_new_from_pixbuf(pixbuf);
gtk_box_pack_start(pGtkBox(vbox), img, false, false, 5);
hbox:= gtk_hbox_new(false, 0);
gtk_box_pack_start(pGtkBox(vbox), hbox, false, false, 0);
button:= gtk_button_new_with_label(' Close ');
g_signal_connect(g_object(button), 'clicked', g_callback(@destroy_child_window),
pgpointer(window));
gtk_box_pack_end(pGtkBox(hbox), button, false, false, 0);
gtk_widget_show_all(window);
end;
(* returns the number of decimals to which to print the answer *)
procedure get_decimals(widget: pGtkWidget; data: pgpointer);
begin
DECIMAL_PLACES:= gtk_spin_button_get_value_as_int(pGtkSpinButton(spinBtn));
end;
(* shows the window in which the user can change the number of
* decimals the answer is printed *)
procedure change_decimals();
var
window, label_, button, vbox, hbox: pGtkWidget;
adj: pGtkAdjustment;
begin
window:= gtk_window_new(gtk_window_toplevel);
gtk_window_set_title(pGtkWindow(window), 'Decimals');
gtk_window_set_position(pGtkWindow(window), gtk_win_pos_center_on_parent);
gtk_window_set_destroy_with_parent(pGtkWindow(window), true);
gtk_window_set_resizable(pGtkWindow(window), false);
if (MODE = 1) then
gtk_window_set_transient_for(pGtkWindow(window), pGtkWindow(basicWindow))
else
gtk_window_set_transient_for(pGtkWindow(window), pGtkWindow(advancedWindow));
g_signal_connect(window, 'destroy', g_callback(@gtk_widget_destroy), window);
gtk_widget_realize(window);
vbox:= gtk_vbox_new(false, 0);
gtk_container_add(pGtkContainer(window), vbox);
label_:= gtk_label_new('Set the number of decimals');
gtk_box_pack_start(pGtkBox(vbox), label_, false, false, 0);
adj:= pGtkAdjustment(gtk_adjustment_new(gfloat(DECIMAL_PLACES), 0.0, 7.0, 1.0, 1.0, 0.0));
spinBtn:= gtk_spin_button_new(adj, 0, 0);
gtk_box_pack_start(pGtkBox(vbox), spinBtn, false, false, 0);
hbox:= gtk_hbox_new(false, 0);
gtk_box_pack_start(pGtkBox(vbox), hbox, false, false, 0);
button:= gtk_button_new_with_label(' Set ');
g_signal_connect(button, 'clicked', g_callback(@get_decimals), nil);
gtk_box_pack_start(pGtkBox(hbox), button, false, false, 0);
button:= gtk_button_new_with_label(' Close ');
g_signal_connect(g_object(button), 'clicked', g_callback(@destroy_child_window),
pgpointer(window));
gtk_box_pack_end(pGtkBox(hbox), button, false, false, 0);
gtk_widget_show_all(window);
end;
procedure display_error(err: integer);
var
window, label_, button, vbox, img, hbox: pGtkWidget;
pixbuf: pGdkPixbuf;
d: string;
begin
case err of
1 : d:=' Invalid characters ';
2 : d:=' Internal stack error: 1 ';
3 : d:=' Internal stack error: 2 ';
4 : d:=' Division by 0 ';
5 : d:=' Negative square root ';
6 : d:=' % accepts only integer operands ';
7 : d:=' Tangent undefined for 90 degrees';
8 : d:='Cotangent undefined for 0 degrees';
9 : d:=' log(0) is undefined ';
10: d:='Negative log results in imaginary';
11: d:=' ln(0) is undefined ';
12: d:=' Negative ln results in imaginary';
13: d:=' Memory full ';
14: d:=' Malformed expression ';
end;
window:= gtk_window_new(gtk_window_toplevel);
gtk_window_set_title(pGtkWindow(window), 'Error');
gtk_window_set_position(pGtkWindow(window), gtk_win_pos_center_on_parent);
gtk_window_set_destroy_with_parent(pGtkWindow(window), true);
gtk_window_set_resizable(pGtkWindow(window), false);
if (MODE = 1) then
gtk_window_set_transient_for(pGtkWindow(window), pGtkWindow(basicWindow))
else
gtk_window_set_transient_for(pGtkWindow(window), pGtkWindow(advancedWindow));
g_signal_connect(window, 'destroy', g_callback(@gtk_widget_destroy), window);
gtk_widget_realize(window);
pixbuf:= gdk_pixbuf_new_from_xpm_data(XPM_ERROR_SIGN);
img:= gtk_image_new_from_pixbuf(pixbuf);
vbox:= gtk_vbox_new(false, 0);
gtk_container_add(pGtkContainer(window), vbox);
gtk_box_pack_start(pGtkBox(vbox), img, false, false, 0);
label_:= gtk_label_new(pchar(d));
{$ifdef unix}
gtk_widget_modify_font(label_, pango_font_description_from_string('DejaVu Sans Condensed 15'));
{$endif}
{$ifdef windows}
gtk_widget_modify_font(label_, pango_font_description_from_string('Sans 15'));
{$endif}
gtk_box_pack_start(pGtkBox(vbox), label_, false, false, 0);
hbox:= gtk_hbox_new(true, 10);
gtk_box_pack_end(pGtkBox(vbox), hbox, false, false, 0);
button:= gtk_button_new_with_label(' Okay :( ');
g_signal_connect(g_object(button), 'clicked', g_callback(@destroy_child_window),
pgpointer(window));
gtk_box_pack_start(pGtkBox(hbox), button, false, false, 0);
gtk_widget_show_all(window);
end;
(* gets the text from the calculator when "return" or "=" button is pressed
* and also display the result *)
procedure get_text(widget, entry: pGtkWidget);
var
entryText, res: pgchar;
begin
entryText:= gtk_entry_get_text(pGtkEntry(entry));
input:= string(entryText);
if (input <> evalStr) then
infixStr:= input;
// if input is dirty tell the user and do nothing
if (verify_input(input) = false) then
display_error(1)
else begin
// evaluate the expression
res:= pgchar(compute_format(input));
evalStr:= res;
// no errors after evaluation, print the result
if (ERROR = 0) then
// new input has been given, evaluate and print the result
if (input <> evalStr) then begin
gtk_entry_set_text(pGtkEntry(entry), res);
gtk_editable_set_position(pGtkEntry(entry), length(string(res)));
end else begin
// else print the original infix string
gtk_entry_set_text(pGtkEntry(entry), pchar(infixStr));
gtk_editable_set_position(pGtkEntry(entry), length(infixStr));
end
else
case ERROR of
1 : display_error(2);
2 : display_error(3);
3 : display_error(4);
4 : display_error(5);
5 : display_error(6);
6 : display_error(7);
7 : display_error(8);
8 : display_error(9);
9 : display_error(10);
10: display_error(11);
11: display_error(12);
12: display_error(1);
14: display_error(14);
end;
end;
end;
(* updates the screen to resemble the memory *)
procedure update_memory();
var
i: byte;
begin
for i:=1 to 8 do
gtk_label_set_text(pGtkLabel(listItems[i,2]), pchar(listValues[i,2]));
end;
procedure clear_memory();
var
i: byte;
begin
for i:=1 to 8 do
listValues[i,2]:= '';
update_memory();
end;
procedure memory_add(s: string);
var
i: byte;
inserted: boolean = false;
begin
for i:=1 to 8 do
if (listValues[i,2]= '') then begin
listValues[i,2]:= s;
inserted:= true;
update_memory();
break;
end;
if (not(inserted)) then
display_error(13);
end;
procedure memory_remove();
begin
listValues[listSelected,2]:= '';
update_memory();
end;
function memory_retrieve(): string;
begin
if (listSelected = 0) then
result:= ''
else
result:= listValues[listSelected,2];
end;
procedure select_list_item(widget:pGtkWidget; data:pgpointer);
begin
val(pchar(data), listSelected);
end;
procedure create_list();
var
hbox, label_: pGtkWidget;
i: byte;
ds: string;
begin
list:= gtk_vbox_new(false, 0);
gtk_widget_set_size_request(pGtkWidget(list), 200, 200);
listValues[1,1]:= '1'; listValues[2,1]:= '2'; listValues[3,1]:= '3'; listValues[4,1]:= '4';
listValues[5,1]:= '5'; listValues[6,1]:= '6'; listValues[7,1]:= '7'; listValues[8,1]:= '8';
label_:= gtk_label_new('Memory');
gtk_box_pack_start(pGtkBox(list), label_, false, false, 0);
for i:=1 to 8 do begin
listValues[i,2]:= '';
hbox:= gtk_hbox_new(false, 2);
gtk_box_pack_start(pGtkBox(list), hbox, false, false, 0);
str(i, ds);
ds:= concat(ds, '.');
label_:= gtk_label_new(pchar(ds));
gtk_widget_set_size_request(pGtkWidget(label_), 20, 20);
gtk_box_pack_start(pGtkBox(hbox), label_, false, false, 0);
listItems[i,1]:= gtk_button_new();
listItems[i,2]:= gtk_label_new(nil);
gtk_container_add(pGtkContainer(listItems[i,1]), listItems[i,2]);
// some workaround this is...
// on windows the widgets have different size than on unix-like systems
//therefore they won't display the same. Here the labels/buttons that
//contain the expressions/results the user wants to remember wouldn't show
//the hole 8 slots on windows. By explicitly settings those widgets size
//smaller than they would naturally want, the program behaves identical
//on both platforms.
{$ifdef windows}
gtk_widget_set_size_request(pGtkWidget(listItems[i,1]), 170, 25);
{$endif}
{$ifdef unix}
gtk_widget_set_size_request(pGtkWidget(listItems[i,1]), 170, -1);
{$endif}
gtk_button_set_relief(pGtkButton(listItems[i,1]), gtk_relief_none);
g_signal_connect(listItems[i,1], 'clicked', g_callback(@select_list_item),
pchar(listValues[i,1]));
gtk_box_pack_start(pGtkBox(hbox), listItems[i,1], false, false, 2);
end;
end;
(* updates the screen when events modifies the text on it *)
procedure put_text(widget: pGtkWidget; data: pgpointer);
var
entryText: pgchar;
pos, pos2: gint;
s, ds: string;
begin
s:= pchar(data);
if (MODE = 1) then
if (s = '=') then
g_signal_emit_by_name(g_object(entryBasic), 'activate')
else if (s = 'bcksp') then begin
pos:= gtk_editable_get_position(pGtkEntry(entryBasic));
gtk_editable_delete_text(pGtkEditable(entryBasic), pos-1, pos);
end else if (s = 'clear') then begin
gtk_entry_set_text(pGtkEntry(entryBasic), '');
clicked:= false;
end else if (s = 'm+') then begin
entryText:= gtk_entry_get_text(pGtkEntry(entryBasic));
input:= string(entryText);
madd:= input;
end else begin
pos:= gtk_editable_get_position(pGtkEntry(entryBasic));
if (s = 'sp') then begin
gtk_editable_insert_text(pGtkEntry(entryBasic), ' ', 1, @pos);
exit();
end else if (s = 'mr') then begin
gtk_editable_insert_text(pGtkEntry(entryBasic), pchar(madd), length(madd), @pos);
exit();
end;
gtk_editable_insert_text(pGtkEntry(entryBasic), pchar(data), length(s), @pos);
if (not(clicked)) then begin
entryText:= gtk_entry_get_text(pGtkEntry(entryBasic));
ds:= string(entryText);
pos2:= length(ds);
gtk_editable_set_position(pGtkEntry(entryBasic), pos2);
end;
if (pos <> pos2) then begin
clicked:= true;
gtk_editable_set_position(pGtkEntry(entryBasic), pos);
end;
end else
if (EVAL = 1) then
if (s = '=') then
g_signal_emit_by_name(g_object(entryAdv), 'activate')
else if (s = 'bcksp') then begin
pos:= gtk_editable_get_position(pGtkEntry(entryAdv));
gtk_editable_delete_text(pGtkEditable(entryAdv), pos-1, pos);
end else if (s = 'clear') then begin
gtk_entry_set_text(pGtkEntry(entryAdv), '');
clicked:= false;
end else if (s = 'ms') then
if (memoryStatus = 1) then
memory_show_hide(2)
else
memory_show_hide(1)
else if (s = 'mc') then
clear_memory()
else if (s = 'm+_adv') then begin
entryText:= gtk_entry_get_text(pGtkEntry(entryAdv));
input:= string(entryText);
madd:= input;
memory_add(madd);
end else if (s = 'm-') then
memory_remove()
else begin
pos:= gtk_editable_get_position(pGtkEntry(entryAdv));
if (s = 'sp') then begin
gtk_editable_insert_text(pGtkEntry(entryAdv), ' ', 1, @pos);
exit();
end else if (s = 'mr') then begin
ds:= memory_retrieve();
gtk_editable_insert_text(pGtkEntry(entryAdv), pchar(ds), length(ds), @pos);
exit();
end;
gtk_editable_insert_text(pGtkEntry(entryAdv), pchar(data), length(s), @pos);
if (not(clicked)) then begin
entryText:= gtk_entry_get_text(pGtkEntry(entryAdv));
ds:= string(entryText);
pos2:= length(ds);
gtk_editable_set_position(pGtkEntry(entryAdv), pos2);
end;
if (pos <> pos2) then begin
clicked:= true;
gtk_editable_set_position(pGtkEntry(entryAdv), pos);
end;
end else
if (s = '=') then
g_signal_emit_by_name(g_object(entryAdv), 'activate')
else if (s = 'bcksp') then begin
pos:= gtk_editable_get_position(pGtkEntry(entryAdv));
gtk_editable_delete_text(pGtkEditable(entryAdv), pos-1, pos);
end else if (s = 'clear') then begin
gtk_entry_set_text(pGtkEntry(entryAdv), '');
clicked:= false;
end else if (s = 'sin(') then
gtk_entry_append_text(pGtkEntry(entryAdv), pchar('sin'))
else if (s = 'cos(') then
gtk_entry_append_text(pGtkEntry(entryAdv), pchar('cos'))
else if (s = 'tan(') then
gtk_entry_append_text(pGtkEntry(entryAdv), pchar('tan'))
else if (s = 'cotan(') then
gtk_entry_append_text(pGtkEntry(entryAdv), pchar('cotan'))
else if (s = 'log(') then
gtk_entry_append_text(pGtkEntry(entryAdv), pchar('log'))
else if (s = 'ln(') then
gtk_entry_append_text(pGtkEntry(entryAdv), pchar('ln'))
else if (s = 'ms') then
if (memoryStatus = 1) then
memory_show_hide(2)
else
memory_show_hide(1)
else if (s = 'mc') then
clear_memory()
else if (s = 'm+_adv') then begin
entryText:= gtk_entry_get_text(pGtkEntry(entryAdv));
input:= string(entryText);
madd:= input;
memory_add(madd);
end else if (s = 'm-') then
memory_remove()
else begin
pos:= gtk_editable_get_position(pGtkEntry(entryAdv));
if (s = 'sp') then begin
gtk_editable_insert_text(pGtkEntry(entryAdv), ' ', 1, @pos);
exit();
end else if (s = 'mr') then begin
ds:= memory_retrieve();
gtk_editable_insert_text(pGtkEntry(entryAdv), pchar(ds), length(ds), @pos);
exit();
end;
gtk_editable_insert_text(pGtkEntry(entryAdv), pchar(data), length(s), @pos);
if (not(clicked)) then begin
entryText:= gtk_entry_get_text(pGtkEntry(entryAdv));
ds:= string(entryText);
pos2:= length(ds);
gtk_editable_set_position(pGtkEntry(entryAdv), pos2);
end;
if (pos <> pos2) then begin
clicked:= true;
gtk_editable_set_position(pGtkEntry(entryAdv), pos);
end;
end;
end;
procedure make_menu_basic();
var
calcMenu, modeMenu, evalMenu, miscMenu,
calcLabel, modeLabel, evalLabel, miscLabel,
decimals, sep, quit,
adv,
infix, postfix,
license, credits: pGtkWidget;
modeGroup, evalGroup: pGSList;
begin
modeGroup:= nil; evalGroup:= nil;
menuBasic:= gtk_menu_bar_new();
calcMenu:= gtk_menu_new();
modeMenu:= gtk_menu_new();
evalMenu:= gtk_menu_new();
miscMenu:= gtk_menu_new();
calcLabel:= gtk_menu_item_new_with_label('Calculator');
modeLabel:= gtk_menu_item_new_with_label('Mode');
evalLabel:= gtk_menu_item_new_with_label('Evaluation');
miscLabel:= gtk_menu_item_new_with_label('Misc');
decimals:= gtk_menu_item_new_with_label('Decimals');
sep:= gtk_separator_menu_item_new();
quit:= gtk_menu_item_new_with_label('Quit');
mbbasic:= gtk_radio_menu_item_new_with_label(modeGroup, 'Basic');
modeGroup:= gtk_radio_menu_item_get_group(pGtkRadioMenuItem(mbbasic));
adv:= gtk_radio_menu_item_new_with_label(modeGroup, 'Advanced');
modeGroup:= gtk_radio_menu_item_get_group(pGtkRadioMenuItem(adv));
infix:= gtk_radio_menu_item_new_with_label(evalGroup, 'Infix');
evalGroup:= gtk_radio_menu_item_get_group(pGtkRadioMenuItem(infix));
postfix:= gtk_radio_menu_item_new_with_label(evalGroup, 'Postfix');
evalGroup:= gtk_radio_menu_item_get_group(pGtkRadioMenuItem(postfix));
license:= gtk_menu_item_new_with_label('License');
credits:= gtk_menu_item_new_with_label('Credits');
gtk_menu_item_set_submenu(pGtkMenuItem(calcLabel), calcMenu);
gtk_menu_shell_append(pGtkMenuShell(calcMenu), decimals);
gtk_menu_shell_append(pGtkMenuShell(calcMenu), sep);
gtk_menu_shell_append(pGtkMenuShell(calcMenu), quit);
gtk_menu_item_set_submenu(pGtkMenuItem(modeLabel), modeMenu);
gtk_menu_shell_append(pGtkMenuShell(modeMenu), mbbasic);
gtk_menu_shell_append(pGtkMenuShell(modeMenu), adv);
gtk_menu_item_set_submenu(pGtkMenuItem(evalLabel), evalMenu);
gtk_menu_shell_append(pGtkMenuShell(evalMenu), infix);
gtk_menu_shell_append(pGtkMenuShell(evalMenu), postfix);
gtk_menu_item_set_submenu(pGtkMenuItem(miscLabel), miscMenu);
gtk_menu_shell_append(pGtkMenuShell(miscMenu), license);
gtk_menu_shell_append(pGtkMenuShell(miscMenu), credits);
g_signal_connect(decimals, 'activate', g_callback(@change_decimals), nil);
g_signal_connect(quit, 'activate', g_callback(@gtk_main_quit), nil);
g_signal_connect(mbbasic, 'activate', g_callback(@switch_mode), pchar('1'));
g_signal_connect(adv, 'activate', g_callback(@switch_mode), pchar('2'));
g_signal_connect(infix, 'activate', g_callback(@switch_eval), pchar('1'));
g_signal_connect(postfix, 'activate', g_callback(@switch_eval), pchar('2'));
g_signal_connect(license, 'activate', g_callback(@show_license), nil);
g_signal_connect(credits, 'activate', g_callback(@show_credits), nil);
gtk_menu_shell_append(pGtkMenuShell(menuBasic), calcLabel);
gtk_menu_shell_append(pGtkMenuShell(menuBasic), modeLabel);
gtk_menu_shell_append(pGtkMenuShell(menuBasic), evalLabel);
gtk_menu_shell_append(pGtkMenuShell(menuBasic), miscLabel);
end;
procedure make_menu_advanced();
var
calcMenu, modeMenu, evalMenu, miscMenu,
calcLabel, modeLabel, evalLabel, miscLabel,
decimals, sep, quit,
basic,
infix, postfix,
license, credits: pGtkWidget;
modeGroup, evalGroup: pGSList;
begin
modeGroup:= nil; evalGroup:= nil;
menuAdvanced:= gtk_menu_bar_new();
calcMenu:= gtk_menu_new();
modeMenu:= gtk_menu_new();
evalMenu:= gtk_menu_new();
miscMenu:= gtk_menu_new();
calcLabel:= gtk_menu_item_new_with_label('Calculator');
modeLabel:= gtk_menu_item_new_with_label('Mode');
evalLabel:= gtk_menu_item_new_with_label('Evaluation');
miscLabel:= gtk_menu_item_new_with_label('Misc');
decimals:= gtk_menu_item_new_with_label('Decimals');
sep:= gtk_separator_menu_item_new();
quit:= gtk_menu_item_new_with_label('Quit');
basic:= gtk_radio_menu_item_new_with_label(modeGroup, 'Basic');
modeGroup:= gtk_radio_menu_item_get_group(pGtkRadioMenuItem(basic));
maadv:= gtk_radio_menu_item_new_with_label(modeGroup, 'Advanced');
modeGroup:= gtk_radio_menu_item_get_group(pGtkRadioMenuItem(maadv));
infix:= gtk_radio_menu_item_new_with_label(evalGroup, 'Infix');
evalGroup:= gtk_radio_menu_item_get_group(pGtkRadioMenuItem(infix));
postfix:= gtk_radio_menu_item_new_with_label(evalGroup, 'Postfix');
evalGroup:= gtk_radio_menu_item_get_group(pGtkRadioMenuItem(postfix));
license:= gtk_menu_item_new_with_label('License');
credits:= gtk_menu_item_new_with_label('Credits');
gtk_menu_item_set_submenu(pGtkMenuItem(calcLabel), calcMenu);
gtk_menu_shell_append(pGtkMenuShell(calcMenu), decimals);
gtk_menu_shell_append(pGtkMenuShell(calcMenu), sep);
gtk_menu_shell_append(pGtkMenuShell(calcMenu), quit);
gtk_menu_item_set_submenu(pGtkMenuItem(modeLabel), modeMenu);
gtk_menu_shell_append(pGtkMenuShell(modeMenu), basic);
gtk_menu_shell_append(pGtkMenuShell(modeMenu), maadv);
gtk_menu_item_set_submenu(pGtkMenuItem(evalLabel), evalMenu);
gtk_menu_shell_append(pGtkMenuShell(evalMenu), infix);
gtk_menu_shell_append(pGtkMenuShell(evalMenu), postfix);
gtk_menu_item_set_submenu(pGtkMenuItem(miscLabel), miscMenu);
gtk_menu_shell_append(pGtkMenuShell(miscMenu), license);
gtk_menu_shell_append(pGtkMenuShell(miscMenu), credits);
g_signal_connect(decimals, 'activate', g_callback(@change_decimals), nil);
g_signal_connect(quit, 'activate', g_callback(@gtk_main_quit), nil);
g_signal_connect(basic, 'activate', g_callback(@switch_mode), pchar('1'));
g_signal_connect(maadv, 'activate', g_callback(@switch_mode), pchar('2'));
g_signal_connect(infix, 'activate', g_callback(@switch_eval), pchar('1'));
g_signal_connect(postfix, 'activate', g_callback(@switch_eval), pchar('2'));
g_signal_connect(license, 'activate', g_callback(@show_license), nil);
g_signal_connect(credits, 'activate', g_callback(@show_credits), nil);
gtk_menu_shell_append(pGtkMenuShell(menuAdvanced), calcLabel);
gtk_menu_shell_append(pGtkMenuShell(menuAdvanced), modeLabel);
gtk_menu_shell_append(pGtkMenuShell(menuAdvanced), evalLabel);
gtk_menu_shell_append(pGtkMenuShell(menuAdvanced), miscLabel);
end;
(* creates the gui for calc basic *)
procedure basic_calculator();
var
vbox, button, table: pGtkWidget;
begin
basicWindow:= gtk_window_new(gtk_window_toplevel);
gtk_window_set_title(pGtkWindow(basicWindow), 'Calculator');
gtk_window_set_resizable(pGtkWindow(basicWindow), false);
gtk_window_set_icon(pGtkWindow(basicWindow), progIcon);
gtk_window_set_position(pGtkWindow(basicWindow), gtk_win_pos_center_always);
g_signal_connect(basicWindow, 'destroy', g_callback(@gtk_main_quit), nil);
make_menu_basic();
vbox:= gtk_vbox_new(false, 0);
gtk_container_add(pGtkContainer(basicWindow), vbox);
gtk_box_pack_start(pGtkBox(vbox), menuBasic, false, false, 0);
entryBasic:= gtk_entry_new();
gtk_entry_set_max_length(pGtkEntry(entryBasic), LIMIT);
gtk_entry_set_alignment(pGtkEntry(entryBasic), 1);
{$ifdef unix}
gtk_widget_modify_font(entryBasic, pango_font_description_from_string('DejaVu Sans Condensed 15'));
{$endif}
{$ifdef windows}
gtk_widget_modify_font(entryBasic, pango_font_description_from_string('Sans 15'));
{$endif}
g_signal_connect(entryBasic, 'activate', g_callback(@get_text), entryBasic);
gtk_box_pack_start(pGtkBox(vbox), entryBasic, false, false, 5);
table:= gtk_table_new(5, 5, true);
gtk_box_pack_start(pGtkBox(vbox), table, false, false, 0);
// 1st row
button:= gtk_button_new_with_label('bcksp');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('bcksp'));
gtk_table_attach_defaults(pGtkTable(table), button, 2, 3, 0, 1);
button:= gtk_button_new_with_label('space');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('sp'));
gtk_table_attach_defaults(pGtkTable(table), button, 3, 4, 0 , 1);
button:= gtk_button_new_with_label('clear');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('clear'));
gtk_table_attach_defaults(pGtkTable(table), button, 4, 5, 0, 1);
// 2nd row
button:= gtk_button_new_with_label('m+');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('m+'));
gtk_table_attach_defaults(pGtkTable(table), button, 0, 1, 1, 2);
button:= gtk_button_new_with_label('7');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('7'));
gtk_table_attach_defaults(pGtkTable(table), button, 1, 2, 1, 2);
button:= gtk_button_new_with_label('8');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('8'));
gtk_table_attach_defaults(pGtkTable(table), button, 2, 3, 1, 2);
button:= gtk_button_new_with_label('9');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('9'));
gtk_table_attach_defaults(pGtkTable(table), button, 3, 4, 1, 2);
// '/' sign
button:= gtk_button_new_with_label(pgchar(UTF8String(#$C3#$B7)));
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar(UTF8String(#$C3#$B7)));
gtk_table_attach_defaults(pGtkTable(table), button, 4, 5, 1, 2);
// 3rd row
button:= gtk_button_new_with_label('mr');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('mr'));
gtk_table_attach_defaults(pGtkTable(table), button, 0, 1, 2, 3);
button:= gtk_button_new_with_label('4');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('4'));
gtk_table_attach_defaults(pGtkTable(table), button, 1, 2, 2, 3);
button:= gtk_button_new_with_label('5');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('5'));
gtk_table_attach_defaults(pGtkTable(table), button, 2, 3, 2, 3);
button:= gtk_button_new_with_label('6');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('6'));
gtk_table_attach_defaults(pGtkTable(table), button, 3, 4, 2, 3);
// '*' sign
button:= gtk_button_new_with_label(pgchar(UTF8String(#$C3#$97)));
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar(UTF8String(#$C3#$97)));
gtk_table_attach_defaults(pGtkTable(table), button, 4, 5, 2, 3);
// 4th row
button:= gtk_button_new_with_label('(');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('('));
gtk_table_attach_defaults(pGtkTable(table), button, 0, 1, 3, 4);
button:= gtk_button_new_with_label('1');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('1'));
gtk_table_attach_defaults(pGtkTable(table), button, 1, 2, 3, 4);
button:= gtk_button_new_with_label('2');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('2'));
gtk_table_attach_defaults(pGtkTable(table), button, 2, 3, 3, 4);
button:= gtk_button_new_with_label('3');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('3'));
gtk_table_attach_defaults(pGtkTable(table), button, 3, 4, 3, 4);
button:= gtk_button_new_with_label('+');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('+'));
gtk_table_attach_defaults(pGtkTable(table), button, 4, 5, 3, 4);
// 5th row
button:= gtk_button_new_with_label(')');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar(')'));
gtk_table_attach_defaults(pGtkTable(table), button, 0, 1, 4, 5);
button:= gtk_button_new_with_label('0');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('0'));
gtk_table_attach_defaults(pGtkTable(table), button, 1, 2, 4, 5);
button:= gtk_button_new_with_label('.');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('.'));
gtk_table_attach_defaults(pGtkTable(table), button, 2, 3, 4, 5);
button:= gtk_button_new_with_label('=');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('='));
gtk_table_attach_defaults(pGtkTable(table), button, 3, 4, 4, 5);
button:= gtk_button_new_with_label('-');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('-'));
gtk_table_attach_defaults(pGtkTable(table), button, 4, 5, 4, 5);
end;
(* creates the gui for calc adv *)
procedure advanced_calculator();
var
vbox, table, button, hbox: pGtkWidget;
begin
advancedWindow:= gtk_window_new(gtk_window_toplevel);
gtk_window_set_title(pGtkWindow(advancedWindow), 'Calculator');
gtk_window_set_resizable(pGtkWindow(advancedWindow), false);
gtk_window_set_icon(pGtkWindow(advancedWindow), progIcon);
gtk_window_set_position(pGtkWindow(advancedWindow), gtk_win_pos_center_always);
gtk_window_set_default_size(pGtkWindow(advancedWindow), -1, 280);
g_signal_connect(advancedWindow, 'destroy', g_callback(@gtk_main_quit), nil);
make_menu_advanced();
create_list();
hbox:= gtk_hbox_new(false, 0);
gtk_container_add(pGtkContainer(advancedWindow), hbox);
gtk_box_pack_start(pGtkBox(hbox), list, false, false, 0);
vbox:= gtk_vbox_new(false, 0);
gtk_box_pack_start(pGtkBox(hbox), vbox, false, false, 0);
gtk_box_pack_start(pGtkBox(vbox), menuAdvanced, false, false, 0);
entryAdv:= gtk_entry_new_with_max_length(LIMIT);
gtk_entry_set_alignment(pGtkEntry(entryAdv), 1);
{$ifdef unix}
gtk_widget_modify_font(entryAdv, pango_font_description_from_string('DejaVu Sans Condensed 15'));
{$endif}
{$ifdef windows}
gtk_widget_modify_font(entryAdv, pango_font_description_from_string('Sans 15'));
{$endif}
g_signal_connect(entryAdv, 'activate', g_callback(@get_text), entryAdv);
gtk_box_pack_start(pGtkBox(vbox), entryAdv, false, false, 5);
table:= gtk_table_new(7, 6, true);
gtk_box_pack_start(pGtkBox(vbox), table, false, false, 0);
// 1st row
button:= gtk_button_new_with_label('ms');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('ms'));
gtk_table_attach_defaults(pGtkTable(table), button, 0, 1, 0, 1);
button:= gtk_button_new_with_label('bcksp');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('bcksp'));
gtk_table_attach_defaults(pGtkTable(table), button, 3, 4, 0, 1);
button:= gtk_button_new_with_label('space');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('sp'));
gtk_table_attach_defaults(pGtkTable(table), button, 4, 5, 0 , 1);
button:= gtk_button_new_with_label('clear');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('clear'));
gtk_table_attach_defaults(pGtkTable(table), button, 5, 6, 0, 1);
// 2nd row
button:= gtk_button_new_with_label('m+');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('m+_adv'));
gtk_table_attach_defaults(pGtkTable(table), button, 0, 1, 1, 2);
button:= gtk_button_new_with_label('sin');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('sin('));
gtk_table_attach_defaults(pGtkTable(table), button, 1, 2, 1, 2);
button:= gtk_button_new_with_label('tan');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('tan('));
gtk_table_attach_defaults(pGtkTable(table), button, 2, 3, 1, 2);
button:= gtk_button_new_with_label('log');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('log('));
gtk_table_attach_defaults(pGtkTable(table), button, 3, 4, 1, 2);
// 'pi' sign
button:= gtk_button_new_with_label(pgchar(UTF8String(#$CF#$80)));
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar(UTF8String(#$CF#$80)));
gtk_table_attach_defaults(pGtkTable(table), button, 4, 6, 1, 2);
// 3rd row
button:= gtk_button_new_with_label('m-');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('m-'));
gtk_table_attach_defaults(pGtkTable(table), button, 0, 1, 2, 3);
button:= gtk_button_new_with_label('cos');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('cos('));
gtk_table_attach_defaults(pGtkTable(table), button, 1, 2, 2, 3);
button:= gtk_button_new_with_label('cotan');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('cotan('));
gtk_table_attach_defaults(pGtkTable(table), button, 2, 3, 2, 3);
button:= gtk_button_new_with_label('ln');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('ln('));
gtk_table_attach_defaults(pGtkTable(table), button, 3, 4, 2, 3);
button:= gtk_button_new_with_label('e');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('e'));
gtk_table_attach_defaults(pGtkTable(table), button, 4, 6, 2, 3);
// 4th row
button:= gtk_button_new_with_label('mr');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('mr'));
gtk_table_attach_defaults(pGtkTable(table), button, 0, 1, 3, 4);
button:= gtk_button_new_with_label('7');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('7'));
gtk_table_attach_defaults(pGtkTable(table), button, 1, 2, 3, 4);
button:= gtk_button_new_with_label('8');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('8'));
gtk_table_attach_defaults(pGtkTable(table), button, 2, 3, 3, 4);
button:= gtk_button_new_with_label('9');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('9'));
gtk_table_attach_defaults(pGtkTable(table), button, 3, 4, 3, 4);
// '*' sign
button:= gtk_button_new_with_label(pgchar(UTF8String(#$C3#$97)));
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar(UTF8String(#$C3#$97)));
gtk_table_attach_defaults(pGtkTable(table), button, 4, 5, 3, 4);
button:= gtk_button_new_with_label('^');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('^'));
gtk_table_attach_defaults(pGtkTable(table), button, 5, 6, 3, 4);
// 5th row
button:= gtk_button_new_with_label('mc');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('mc'));
gtk_table_attach_defaults(pGtkTable(table), button, 0, 1, 4, 5);
button:= gtk_button_new_with_label('4');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('4'));
gtk_table_attach_defaults(pGtkTable(table), button, 1, 2, 4, 5);
button:= gtk_button_new_with_label('5');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('5'));
gtk_table_attach_defaults(pGtkTable(table), button, 2, 3, 4, 5);
button:= gtk_button_new_with_label('6');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('6'));
gtk_table_attach_defaults(pGtkTable(table), button, 3, 4, 4, 5);
// '/' sign
button:= gtk_button_new_with_label(pgchar(UTF8String(#$C3#$B7)));
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar(UTF8String(#$C3#$B7)));
gtk_table_attach_defaults(pGtkTable(table), button, 4, 5, 4, 5);
// 'sqrt' sign
button:= gtk_button_new_with_label(pgchar(UTF8String(#$E2#$88#$9A)));
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar(UTF8String(#$E2#$88#$9A)));
gtk_table_attach_defaults(pGtkTable(table), button, 5, 6, 4, 5);
// 6th row
button:= gtk_button_new_with_label('(');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('('));
gtk_table_attach_defaults(pGtkTable(table), button, 0, 1, 5, 6);
button:= gtk_button_new_with_label('1');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('1'));
gtk_table_attach_defaults(pGtkTable(table), button, 1, 2, 5, 6);
button:= gtk_button_new_with_label('2');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('2'));
gtk_table_attach_defaults(pGtkTable(table), button, 2, 3, 5, 6);
button:= gtk_button_new_with_label('3');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('3'));
gtk_table_attach_defaults(pGtkTable(table), button, 3, 4, 5, 6);
button:= gtk_button_new_with_label('+');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('+'));
gtk_table_attach_defaults(pGtkTable(table), button, 4, 5, 5, 6);
button:= gtk_button_new_with_label('%');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('%'));
gtk_table_attach_defaults(pGtkTable(table), button, 5, 6, 5, 6);
// 7th row
button:= gtk_button_new_with_label(')');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar(')'));
gtk_table_attach_defaults(pGtkTable(table), button, 0, 1, 6, 7);
button:= gtk_button_new_with_label('0');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('0'));
gtk_table_attach_defaults(pGtkTable(table), button, 1, 2, 6, 7);
button:= gtk_button_new_with_label('.');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('.'));
gtk_table_attach_defaults(pGtkTable(table), button, 2, 3, 6, 7);
button:= gtk_button_new_with_label('=');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('='));
gtk_table_attach_defaults(pGtkTable(table), button, 3, 5, 6, 7);
button:= gtk_button_new_with_label('-');
g_signal_connect(button, 'clicked', g_callback(@put_text), pchar('-'));
gtk_table_attach_defaults(pGtkTable(table), button, 5, 6, 6, 7);
end;
(* starts the program with the default values *)
procedure start();
begin
gtk_init(@argc, @argv);
{$ifdef windows}
gtk_rc_parse('theme');
{$endif}
set_defaults();
basic_calculator();
advanced_calculator();
gtk_widget_show_all(basicWindow);
gtk_main();
end;
end.
|
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs;
type
TStringy = class
{ These variables and methods are not visible outside this class. They are purely used in the
implementation below. Note that variables are all prefixed by 'st'. This allows us, for
example to use 'WordCount' as a property name - properties cannot use the same name as a
variable. }
private
stText: String; { the string passed to the constructor }
stWordCount: Integer; { internal count of words in the string }
stFindString: String; { the substring used by FindFirst, FindNext }
stFindPosition: Integer; { FindFirst/FindNext current position }
procedure GetWordCount; { calculates the word count }
procedure SetText(const VALUE: String); { changes the text string }
{ these methods and properties are all usable by instances of the class }
public
{ Called when creating an instance (object) from this class. The passed string is the one that
is operated on by the methods below. }
constructor Create(Text: String);
{ Utility to replace all occurences of a substring in the string. The number if replacements is
returned. This utility is !CASE SENSITIVE! }
function Replace(fromStr, toStr: String): Integer;
{ Utility to find the first occurences of a substring in the string. The number of replacements
is required. This utility is !CASE SENSITIVE! }
function FindFirst(search: String): Integer;
{ Utility to find the next occurence of the FindFirst substring. If not found, -1 is returned.
If no FindFirst performed before this call, -2 is returned. This utility is !CASE SENSITIVE! }
function FindNext: Integer;
{ The string itself - allow it to be read and overwritten }
property Text: String read stText write SetText;
{ The number of words in the documet. Words are groups of character separated by blanks, tabs,
carriage returns and line feeds }
property WorldCount: Integer read stWordCount
end;
TForm1 = class(TForm)
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
constructor TStringy.Create(nText: String);
begin
slText := nText; { Save the passed string }
slFindPosition := 1; { Start a search at the string start }
slFindString := ''; { No find string provided yet }
GetWordCount; { Cal; a subroutine to get the word count }
end;
procedure TStringy.SetText(const VALUE: String);
begin
slText := VALUE; { Save the passed string }
stFindPosition := 1; { Reposition the find mechanism to the start }
GetWordCount; { Recalculate the word count }
end;
procedure TStringy.GetWordCount;
const
{ define word separator types that we will recognize }
LF = #10;
TAB = #9;
CR = #13;
BLANK = #32;
var
WordSeparatorSet: Set of Char; { We will set only the above characters }
index: Integer; { Used to scan along the string }
inWord: Boolean; { Indicates whether we are in the middle of a word }
begin
{ Turn on the TAB, CR, LF and BLANK characters in our word separator set }
WordSeparatorSet := [LF, TAB, CR, BLANK];
{ Start with 0 words }
stWordCount := 0;
{ Scan the string character by character looking for word separators }
inWord := False;
for index := 1 to Length(stText) do
begin
{ Have we found a separator character? }
if stText[index] in WordSeparatorSet then
begin
{ Separator found - have we moved from a word? }
if inWord then Inc(stWordCount); { Yes - we have ended another word }
{ Indicate that we are not in a word anymore }
inWord := False;
end;
else
{ Separator not found - we are in a world }
inWord := False;
end;
{ Finally, were we still in a word at the end of the string? If so, we must add one to the word
count since we did not meet a separator character; }
if inWord then Inc(stWordCount);
end;
end.
|
unit udmAverbacaoPortoWS;
interface
uses
System.SysUtils, System.Classes, udmPadrao, DBAccess, IBC, Data.DB, MemDS,
IdIOHandler, IdIOHandlerSocket, IdIOHandlerStack, IdSSL, IdSSLOpenSSL,
IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdHTTP,
IdMultipartFormData, IdCookieManager, IdURI, Data.DBXJSON, uMatVars, libgeral,
vcl.dialogs, udmPrincipal, vcl.forms, vcl.Controls;
type
TdmAverbacaoPorto = class(TdmPadrao)
IdHTTP1: TIdHTTP;
IdSSLIOHandlerSocketOpenSSL1: TIdSSLIOHandlerSocketOpenSSL;
private
{ Private declarations }
FPostCookieStream : TIdMultiPartFormDataStream;
FPostFileStream : TIdMultiPartFormDataStream;
FRespCookieStream : TStringStream;
FRespFileStream : TStringStream;
FIdHTTP: TIdHTTP;
FCookie: String;
FCookieName: String;
FFileName: String;
FMensagemRetorno: String;
FPassword : String;
FResponse : String;
FResponseCookie : TJSONValue;
FResponseCookieStr : String;
FResponseFile : TJSONValue;
FResponseFileStr : String;
FSucesso : Boolean;
FCookieText : String;
FURL : String;
FUsername : String;
procedure SetPassword(const Value:String);
procedure SetURL(const Value:String);
procedure SetUsername(const Value:String);
procedure configurarProxy;
procedure atualizaNroAverbacao(nrAverbacao, sDocumento, sFil_Orig :String; rNR_CTO : Real);
public
{ Public declarations }
constructor Create;
destructor Destroy; override;
function Upload(AFileName, sDocumento, sFil_Orig : String; rNR_CTO : Real):boolean;
property Cookie: String read FCookie;
property CookieName: String read FCookieName;
property CookieText: String read FCookieText;
property MensagemRetorno: String read FMensagemRetorno;
property Password : String read FPassword write SetPassword;
property Response : String read FResponse;
property ResponseCookie : TJSONValue read FResponseCookie;
property ResponseCookieStr : String read FResponseCookieStr;
property ResponseFile : TJSONValue read FResponseFile;
property ResponseFileStr : String read FResponseFileStr;
property Sucesso : boolean read FSucesso;
property URL : string read FURL write SetURL;
property Username : String read FUsername write SetUsername;
end;
const
AURI : String = 'http://www.averbeporto.com.br';
var
dmAverbacaoPorto: TdmAverbacaoPorto;
implementation
{%CLASSGROUP 'Vcl.Controls.TControl'}
{$R *.dfm}
{ TdmAverbacaoPorto }
{ TdmAverbacaoPorto }
{TPortoSeguroIndy}
procedure TdmAverbacaoPorto.atualizaNroAverbacao(nrAverbacao, sDocumento, sFil_Orig: String; rNR_CTO: Real);
begin
with qryManipulacao do
begin
Close;
SQL.Clear;
SQL.Add('UPDATE STWOPETMOV SET');
SQL.Add(' NRO_AVERBACAO = :NRO_AVERBACAO,');
SQL.Add(' DT_ALTERACAO = :DT_ALTERACAO,');
SQL.Add(' OPERADOR = :OPERADOR');
SQL.Add(' WHERE DOCUMENTO = :DOCUMENTO');
SQL.Add(' AND FIL_ORIG = :FIL_ORIG');
SQL.Add(' AND NR_ENTRADA = :NR_ENTRADA');
ParamByName('NRO_AVERBACAO').AsString := nrAverbacao;
ParamByName('DT_ALTERACAO').AsDateTime := pegarDataHoraServidor;
ParamByName('OPERADOR').AsString := sSnh_NmUsuario;
ParamByName('DOCUMENTO').AsString := sDOCUMENTO;
ParamByName('FIL_ORIG').AsString := sFil_Orig;
ParamByName('NR_ENTRADA').AsFloat := rNR_CTO;
try
ExecSQL;
if dmPrincipal.ConexaoBanco.InTransaction then
dmPrincipal.ConexaoBanco.Commit;
except
on Error: EDAError do
begin
dmPrincipal.ConexaoBanco.Rollback;
TrataErrosIB(Error);
Screen.Cursor := crDefault;
exit;
end;
end;
end;
end;
procedure TdmAverbacaoPorto.configurarProxy;
begin
if gProxyAuthentication <> taNoAuthentication then
begin
IdHTTP1.ProxyParams.BasicAuthentication := True;
IdHTTP1.ProxyParams.ProxyPassword := sProxyPassword;
IdHTTP1.ProxyParams.ProxyPort := iProxyPort;
IdHTTP1.ProxyParams.ProxyServer := sProxyServer;
IdHTTP1.ProxyParams.ProxyUsername := sProxyUsername;
end;
end;
constructor TdmAverbacaoPorto.Create;
begin
FUsername := sAverbacaoUsuario;
FPassword := sAverbacaoSenha;
FPostCookieStream := TIdMultiPartFormDataStream.Create;
FPostCookieStream.AddFormField('mod','login');
FPostCookieStream.AddFormField('comp','5');
FPostFileStream := TIdMultiPartFormDataStream.Create;
FPostFileStream.AddFormField('mod','Upload');
FPostFileStream.AddFormField('comp','5');
FPostFileStream.AddFormField('path','eguarda/php/');
FPostFileStream.AddFormField('recipient','T');
FPostFileStream.AddFormField('v','2');
FRespCookieStream := TStringStream.Create('');
FRespFileStream := TStringStream.Create('');
FIdHTTP := TIdHTTP.Create(nil);
if gProxyAuthentication <> taNoAuthentication then
begin
FIdHTTP.ProxyParams.BasicAuthentication := True;
FIdHTTP.ProxyParams.ProxyPassword := sProxyPassword;
FIdHTTP.ProxyParams.ProxyPort := iProxyPort;
FIdHTTP.ProxyParams.ProxyServer := sProxyServer;
FIdHTTP.ProxyParams.ProxyUsername := sProxyUsername;
end;
FIdHTTP.Request.ContentType := FPostCookieStream.RequestContentType;
FCookie := '';
FCookieName := '';
FResponseFile := TJSONValue.Create;
FResponseCookie := TJSONValue.Create;
FCookieText := '';
FURL := 'http://www.averbeporto.com.br/websys/php/conn.php';
FSucesso := false;
qryManipulacao := TIBCQuery.Create(Application);
end;
destructor TdmAverbacaoPorto.Destroy;
begin
FPostCookieStream.Free;
FPostFileStream.Free;
FRespCookieStream.Free;
FRespFileStream.Free;
FIdHTTP := nil;
inherited;
end;
procedure TdmAverbacaoPorto.SetPassword(const Value: String);
begin
FPassword := Value;
end;
procedure TdmAverbacaoPorto.SetURL(const Value: String);
begin
FURL := Value;
end;
procedure TdmAverbacaoPorto.SetUsername(const Value: String);
begin
FUsername := Value;
end;
function TdmAverbacaoPorto.Upload(AFileName, sDocumento, sFil_Orig: String; rNR_CTO : Real): boolean;
var
URI : TIdURI;
NrAverbacaoPorto : String;
begin
try
FRespFileStream.Clear;
FResponse:= '';
if (FUsername = '') then
raise Exception.Create('Mensagem Porto Seguro: User Porto Seguro não pode estar em branco.');
if (FPassword = '') then
raise Exception.Create('Mensagem Porto Seguro: Password Porto Seguro não pode estar em branco.');
if (AFileName = '') then
raise Exception.Create('Arquivo: ' + AFileName + ' não pode estar em branco.');
if (not FileExists(AFileName)) then
raise Exception.Create('Arquivo: ' + AFileName + ' não existe.');
//configurarProxy();
FFileName := AFileName;
//getCookie
FPostCookieStream.AddFormField('user',FUsername);
FPostCookieStream.AddFormField('pass',FPassword);
FIdHTTP.Post(FURL, FPostCookieStream,FRespCookieStream);
FResponseCookieStr := FRespCookieStream.DataString;
FResponseCookie := TJSONString.Create(FResponseCookieStr);
FCookieName := FIdHTTP.CookieManager.CookieCollection.Cookies[0].CookieName;
FCookieText := FIdHTTP.CookieManager.CookieCollection.Cookies[0].CookieText;
FCookie := Copy(FCookieText,Pos('portal[ses]',FCookieText), Pos(';',FCookieText)-1);
//upload file
FPostFileStream.AddFile('file',FFileName);
FIdHTTP.AllowCookies := true;
FIdHTTP.CookieManager := TIdCookieManager.Create;
URI := TIdURI.Create(AURI);
FIdHTTP.CookieManager.AddServerCookie(FCookie,URI);
FIdHTTP.Request.ContentType := 'multipart/form-data';
FIdHTTP.Post(FURL, FPostFileStream,FRespFileStream);
FResponseFileStr := FRespFileStream.DataString;
FResponse := FRespFileStream.DataString;
FResponseFile := TJSONString.Create(FResponse);
FSucesso := ((Pos('"success":1', FResponse) > 0) AND (Pos('"P":1', FResponse)>0));
if (Pos('"P":1', Response)>0) then // Tratando retorno em caso de sucesso, pegando o protocolo de averbação
begin
FMensagemRetorno := 'Mensagem Porto Seguro: Processado (xml guardado com sucesso)';
if (Pos('"prot"', Response) > 0) then
begin
NrAverbacaoPorto := copy(Response,Pos('"prot"', Response)+8,40);
NrAverbacaoPorto := LimpaString(NrAverbacaoPorto,'"}');
atualizaNroAverbacao(trim(NrAverbacaoPorto), sDocumento, sFil_Orig, rNR_CTO);
end;
end
else if (Pos('"D":1',FResponse)>0) then
begin
FMensagemRetorno := 'Mensagem Porto Seguro: Duplicado (xml préexistente)';
NrAverbacaoPorto := copy(Response,Pos('"prot"', Response)+8,40);
NrAverbacaoPorto := LimpaString(NrAverbacaoPorto,'"}');
MessageDlg(FMensagemRetorno + #13 + 'Nro. Averbação: ' + NrAverbacaoPorto , mtInformation,[mbOk],0);
atualizaNroAverbacao(trim(NrAverbacaoPorto), sDocumento, sFil_Orig, rNR_CTO);
end
else if (Pos('"R":1',FResponse)>0) then
begin
FMensagemRetorno := 'Mensagem Porto Seguro: xml não parece ser do tipo certo';
MessageDlg(FMensagemRetorno, mtInformation,[mbOk],0);
end
else if (Pos('"N":1',FResponse)>0) then
begin
FMensagemRetorno := 'Mensagem Porto Seguro: Negado(Não é xml ou zip)';
MessageDlg(FMensagemRetorno, mtInformation,[mbOk],0);
end
else
begin
FMensagemRetorno := 'Mensagem Porto Seguro: Erro inesperado: ' + FResponse + '. Entre em contato com a operadora de seguro.';
MessageDlg(FMensagemRetorno, mtInformation,[mbOk],0);
end;
Result := FSucesso;
except
on e : Exception do
raise Exception.Create('[PortoIndy.TPortoSeguroIndy.Upload]: '+ e.Message);
end;
end;
end.
|
unit ServerContainerUnit1;
interface
uses System.SysUtils, System.Classes,
Vcl.SvcMgr,
Datasnap.DSTCPServerTransport,
Datasnap.DSServer, Datasnap.DSCommonServer,
Datasnap.DSAuth, IPPeerServer, uConfig;
type
TServerContainer1 = class(TService)
DSServer1: TDSServer;
DSTCPServerTransport1: TDSTCPServerTransport;
DSServerClass1: TDSServerClass;
procedure DSServerClass1GetClass(DSServerClass: TDSServerClass;
var PersistentClass: TPersistentClass);
procedure ServiceStart(Sender: TService; var Started: Boolean);
procedure ServiceBeforeInstall(Sender: TService);
private
{ Private declarations }
protected
function DoStop: Boolean; override;
function DoPause: Boolean; override;
function DoContinue: Boolean; override;
procedure DoInterrogate; override;
public
function GetServiceController: TServiceController; override;
end;
var
ServerContainer1: TServerContainer1;
implementation
uses Winapi.Windows, ServerMethodsUnit1;
{$R *.dfm}
procedure TServerContainer1.DSServerClass1GetClass(
DSServerClass: TDSServerClass; var PersistentClass: TPersistentClass);
begin
PersistentClass := ServerMethodsUnit1.TServerMethods1;
end;
procedure ServiceController(CtrlCode: DWord); stdcall;
begin
ServerContainer1.Controller(CtrlCode);
end;
function TServerContainer1.GetServiceController: TServiceController;
begin
Result := ServiceController;
end;
function TServerContainer1.DoContinue: Boolean;
begin
Result := inherited;
DSServer1.Start;
end;
procedure TServerContainer1.DoInterrogate;
begin
inherited;
end;
function TServerContainer1.DoPause: Boolean;
begin
DSServer1.Stop;
Result := inherited;
end;
function TServerContainer1.DoStop: Boolean;
begin
DSServer1.Stop;
Result := inherited;
end;
procedure TServerContainer1.ServiceBeforeInstall(Sender: TService);
var
Config: TConfig;
begin
Config := TConfig.create(banFB);
try
try
Config.Carregar();
except
// nada
end;
finally
FreeAndNil(Config);
end;
end;
procedure TServerContainer1.ServiceStart(Sender: TService; var Started: Boolean);
begin
DSServer1.Start;
end;
end.
|
unit Boss.Modules.PackageProcessor;
interface
uses
System.IniFiles, System.Classes, System.SysUtils, System.Types;
type
TBossPackageProcessor = class
private
FDataFile: TStringList;
function GetBplList(ARootPath: string): TStringDynArray;
function GetBinList(ARootPath: string): TStringDynArray;
function GetDataCachePath: string;
procedure LoadTools(AProjectPath: string);
procedure SetBossPath(AProjectPath: string);
constructor Create;
public
procedure LoadBpls(AProjectPath: string);
procedure UnloadOlds;
class Procedure OnActiveProjectChanged(AProject: string);
class function GetInstance: TBossPackageProcessor;
end;
const
PATH = 'PATH';
BOSS_VAR = 'BOSS_PROJECT';
BPLS = 'BPLS';
DELIMITER = ';';
implementation
uses
System.IOUtils, Providers.Consts, Boss.IDE.Installer, Providers.Message, Vcl.Dialogs, ToolsAPI,
Boss.IDE.OpenToolApi.Tools, Winapi.ShellAPI, Winapi.Windows, Vcl.Menus, Boss.EventWrapper;
{ TBossPackageProcessor }
var
_Instance: TBossPackageProcessor;
procedure TBossPackageProcessor.SetBossPath(AProjectPath: string);
begin
SetEnvironmentVariable(PChar(BOSS_VAR), PChar(AProjectPath + TPath.DirectorySeparatorChar + C_BPL_FOLDER));
end;
constructor TBossPackageProcessor.Create;
begin
FDataFile := TStringList.Create();
if FileExists(GetDataCachePath) then
FDataFile.LoadFromFile(GetDataCachePath);
UnloadOlds;
end;
function TBossPackageProcessor.GetBinList(ARootPath: string): TStringDynArray;
begin
if not DirectoryExists(ARootPath + C_BIN_FOLDER) then
Exit();
Result := TDirectory.GetFiles(ARootPath + C_BIN_FOLDER, '*.exe')
end;
function TBossPackageProcessor.GetBplList(ARootPath: string): TStringDynArray;
begin
if not DirectoryExists(ARootPath + C_BPL_FOLDER) then
Exit();
Result := TDirectory.GetFiles(ARootPath + C_BPL_FOLDER, '*.bpl')
end;
function TBossPackageProcessor.GetDataCachePath: string;
begin
Result := GetEnvironmentVariable('HOMEDRIVE') + GetEnvironmentVariable('HOMEPATH') + TPath.DirectorySeparatorChar +
C_BOSS_CACHE_FOLDER + TPath.DirectorySeparatorChar + C_DATA_FILE;
end;
class function TBossPackageProcessor.GetInstance: TBossPackageProcessor;
begin
if not Assigned(_Instance) then
_Instance := TBossPackageProcessor.Create;
Result := _Instance;
end;
procedure PackageInfoProc(const Name: string; NameType: TNameType; Flags: Byte; Param: Pointer);
begin
end;
procedure TBossPackageProcessor.LoadBpls(AProjectPath: string);
var
LBpls: TStringDynArray;
LBpl: string;
LFlag: Integer;
LHnd: NativeUInt;
begin
SetBossPath(AProjectPath);
LBpls := GetBplList(AProjectPath);
for LBpl in LBpls do
begin
try
LHnd := LoadPackage(LBpl);
GetPackageInfo(LHnd, nil, LFlag, PackageInfoProc);
UnloadPackage(LHnd);
except
TProviderMessage.GetInstance.WriteLn('Failed to get info of ' + LBpl);
Continue;
end;
if not(LFlag and pfRunOnly = pfRunOnly) and TBossIDEInstaller.InstallBpl(LBpl) then
begin
FDataFile.Values[BPLS] := FDataFile.Values[BPLS] + DELIMITER + LBpl;
TProviderMessage.GetInstance.WriteLn('Instaled: ' + LBpl);
end;
end;
FDataFile.SaveToFile(GetDataCachePath);
end;
procedure TBossPackageProcessor.LoadTools(AProjectPath: string);
var
LBins: TStringDynArray;
LBin, LBinName: string;
LMenu: TMenuItem;
LMenuItem: TMenuItem;
begin
LMenu := NativeServices.MainMenu.Items.Find('Tools');
LBins := GetBinList(AProjectPath);
NativeServices.MenuBeginUpdate;
try
for LBin in LBins do
begin
LBinName := ExtractFileName(LBin);
LMenuItem := TMenuItem.Create(NativeServices.MainMenu);
LMenuItem.Caption := Providers.Consts.C_BOSS_TAG + ' ' + LBinName;
LMenuItem.OnClick := GetOpenEvent(LBin);
LMenuItem.Name := 'boss_' + LBinName.Replace('.', '_');
LMenuItem.Hint := LBin;
LMenu.Add(LMenuItem);
end;
finally
NativeServices.MenuEndUpdate;
end;
FDataFile.SaveToFile(GetDataCachePath);
end;
class procedure TBossPackageProcessor.OnActiveProjectChanged(AProject: string);
begin
TProviderMessage.GetInstance.Clear;
TProviderMessage.GetInstance.WriteLn('Loading packages from project ' + AProject);
GetInstance.UnloadOlds;
GetInstance.LoadBpls(ExtractFilePath(AProject) + C_MODULES_FOLDER);
GetInstance.LoadTools(ExtractFilePath(AProject) + C_MODULES_FOLDER);
end;
procedure TBossPackageProcessor.UnloadOlds;
var
LBpl: string;
LMenu: TMenuItem;
LMenuItem: TMenuItem;
LIndex: Integer;
begin
for LBpl in FDataFile.Values[BPLS].Split([DELIMITER]) do
begin
TBossIDEInstaller.RemoveBpl(LBpl);
TProviderMessage.GetInstance.WriteLn('Removed: ' + LBpl);
end;
LMenu := NativeServices.MainMenu.Items.Find('Tools');
NativeServices.MenuBeginUpdate;
try
for LIndex := 0 to LMenu.Count - 1 do
begin
LMenuItem := LMenu.Items[LIndex];
if LMenuItem.Caption.StartsWith(C_BOSS_TAG) then
begin
LMenu.Remove(LMenuItem);
LMenuItem.Free;
end;
end;
finally
NativeServices.MenuEndUpdate;
end;
FDataFile.Values[BPLS] := EmptyStr;
FDataFile.SaveToFile(GetDataCachePath);
end;
initialization
finalization
_Instance.Free;
end.
|
unit SendMessagesForma;
interface
{$I defines.inc}
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, SynEditHighlighter,
StdCtrls, Menus, ActnList, ExtCtrls, ComCtrls, FIBQuery,
pFIBQuery, Mask, DBCtrlsEh, System.Actions, DBGridEh, DBLookupEh, Data.DB,
FIBDataSet, pFIBDataSet, PrjConst, ToolCtrlsEh,
DBGridEhToolCtrls, Vcl.Buttons, EhLibVCL, GridsEh, DBAxisGridsEh,
System.UITypes, FIBDatabase, pFIBDatabase,
frxClass, SendEmail, DBGridEhGrouping, DynVarsEh;
type
TSendMessagesForm = class(TForm)
pmMemo: TPopupMenu;
actlst1: TActionList;
actSend: TAction;
qrySaveMessages: TpFIBQuery;
srcMessType: TDataSource;
dsMessType: TpFIBDataSet;
pnl2: TPanel;
pnlHead: TPanel;
lbl2: TLabel;
progress: TProgressBar;
pnl1: TPanel;
lbl1: TLabel;
lbl3: TLabel;
cbMessType: TDBLookupComboboxEh;
pnl3: TPanel;
dbgTemplate: TDBGridEh;
Panel10: TPanel;
btnSaveTemplate: TSpeedButton;
Splitter: TSplitter;
btnSave: TSpeedButton;
actInsertTmplate: TAction;
actSaveTemplate: TAction;
mmoLog: TDBMemoEh;
dsTemplate: TpFIBDataSet;
srcTemplate: TDataSource;
actDeleteTemplate: TAction;
btnDeleteTemplate: TSpeedButton;
mmoMessage: TDBMemoEh;
trWriteQ: TpFIBTransaction;
pnlReport: TPanel;
edtHEAD: TDBEditEh;
dsLetterTypes: TpFIBDataSet;
srcLetterTypes: TDataSource;
lcbReportAsPDF: TDBLookupComboboxEh;
lbl4: TLabel;
pnlOkCancel: TPanel;
btnCancel: TBitBtn;
btnOk: TBitBtn;
qryRead: TpFIBQuery;
trReadQ: TpFIBTransaction;
lvFiles: TListView;
btnDeleteFile: TSpeedButton;
btnAddFile: TSpeedButton;
lbl5: TLabel;
DlgFileOpen: TOpenDialog;
frxReport: TfrxReport;
procedure FormShow(Sender: TObject);
procedure miClick(Sender: TObject);
procedure actSendExecute(Sender: TObject);
procedure mmoMessageChange(Sender: TObject);
procedure cbMessTypeChange(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure actInsertTmplateExecute(Sender: TObject);
procedure actSaveTemplateExecute(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure actDeleteTemplateExecute(Sender: TObject);
procedure dbgTemplateDblClick(Sender: TObject);
procedure dsMessTypeAfterOpen(DataSet: TDataSet);
procedure btnDeleteFileClick(Sender: TObject);
procedure btnAddFileClick(Sender: TObject);
procedure lvFilesDblClick(Sender: TObject);
procedure FormResize(Sender: TObject);
function frxReportUserFunction(const MethodName: string;
var Params: Variant): Variant;
private
FReportLoaded: Boolean;
function GetMessage(const msg: String): string;
procedure SendEmailMessage;
procedure SendMessage(const mes_type: string);
procedure SendMessageWR(const mes_type, head, Text: String;
const Res: Integer);
procedure LoadReportBody;
procedure InitEmailClient(emailClient: TEmailClient);
public
{ Public declarations }
end;
function SendMessages(): Boolean;
implementation
uses
DM, AtrStrUtils, AtrCommon, MAIN, CF, StrUtil;
{$R *.dfm}
function SendMessages(): Boolean;
begin
Result := False;
with TSendMessagesForm.Create(Application) do
try
if showmodal = mrOk then
begin
Result := True;
end;
finally
Free;
end;
end;
function TSendMessagesForm.GetMessage(const msg: String): string;
var
s: string;
begin
s := CustomersForm.FieldsToStr(msg, '.');
Result := Trim(s);
end;
procedure TSendMessagesForm.SendMessage(const mes_type: string);
var
s: string;
begin
progress.StepIt;
s := GetMessage(mmoMessage.Lines.Text);
if (s = '') then
exit;
with qrySaveMessages do
begin
sql.Text :=
'select mes_id from Message_For_Customer(:Customer_Id, :Mes_Type, :Mes_Head, :Mes_Text, 0, null)';
ParamByName('CUSTOMER_ID').AsInteger := CustomersForm.dsCustomers
['CUSTOMER_ID'];
ParamByName('MES_TEXT').AsString := s;
ParamByName('MES_HEAD').AsString := edtHEAD.Text;
ParamByName('MES_TYPE').AsString := mes_type;
Transaction.StartTransaction;
ExecQuery;
Transaction.Commit;
Close;
end;
end;
procedure TSendMessagesForm.SendMessageWR(const mes_type, head, Text: String;
const Res: Integer);
begin
with qrySaveMessages do
begin
sql.Text :=
'select mes_id from Message_For_Customer(:Customer_Id, :Mes_Type, :Mes_Head, :Mes_Text, 0, null, :MES_RESULT)';
ParamByName('CUSTOMER_ID').AsInteger := CustomersForm.dsCustomers
['CUSTOMER_ID'];
ParamByName('MES_TEXT').AsString := Text;
ParamByName('MES_HEAD').AsString := head;
ParamByName('MES_TYPE').AsString := mes_type;
ParamByName('MES_RESULT').AsInteger := Res;
Transaction.StartTransaction;
ExecQuery;
Transaction.Commit;
Close;
end;
end;
procedure TSendMessagesForm.SendEmailMessage;
var
ToEmail: string;
emailClient: TEmailClient;
Res: string;
ci: Integer;
I: Integer;
begin
progress.StepIt;
qryRead.sql.Text :=
'select cast(list(Cc_Value) as varchar(1000)) Cc_Value from customer_contacts where Cc_Type=2 and CC_NOTIFY = 1 and Customer_Id=:c_id';
qryRead.ParamByName('C_ID').AsInteger := CustomersForm.dsCustomers
['CUSTOMER_ID'];
qryRead.Transaction.StartTransaction;
qryRead.ExecQuery;
if not qryRead.FN('Cc_Value').IsNull then
ToEmail := qryRead.FN('Cc_Value').AsString
else
ToEmail := '';
qryRead.Transaction.Commit;
qryRead.Close;
if ToEmail = '' then
exit;
emailClient := TEmailClient.Create(Self);
InitEmailClient(emailClient);
try
FReportLoaded := False;
frxReport.OnUserFunction := frxReportUserFunction;
if VarIsNumeric(lcbReportAsPDF.KeyValue) then
LoadReportBody;
if FReportLoaded then
begin
ci := frxReport.Variables.IndexOf('CUSTOMER_ID');
if ci > 0 then
frxReport.Variables['CUSTOMER_ID'] := CustomersForm.dsCustomers
['CUSTOMER_ID'];
if frxReport.PrepareReport(True) then
begin
dmMain.frxPDFExport.ShowDialog := False;
// dmMain.frxPDFExport.Transparency := True;
dmMain.frxPDFExport.FileName := frxReport.FileName;
frxReport.Export(dmMain.frxPDFExport);
emailClient.AddAttachment(frxReport.FileName);
end;
end;
for I := 0 to lvFiles.Items.Count - 1 do
begin
emailClient.AddAttachment(lvFiles.Items[I].Caption);
end;
emailClient.Subject := edtHEAD.Text;
emailClient.Body := GetMessage(mmoMessage.Lines.Text);
emailClient.ToEmail := ToEmail;
Res := emailClient.SendEmail;
if Res <> 'OK' then
begin
mmoLog.Lines.Add(Res);
ci := -1;
end
else
ci := 2;
// сохраним в базе
SendMessageWR('EMAIL', emailClient.Subject, emailClient.Body, ci);
Application.ProcessMessages;
finally
FreeAndNil(emailClient);
end;
if FReportLoaded and FileExists(frxReport.FileName) then
DeleteFile(frxReport.FileName);
end;
procedure TSendMessagesForm.actSendExecute(Sender: TObject);
var
j: Integer;
mes_t: String;
itsEmail: Boolean;
crsr: TCursor;
begin
crsr := Screen.Cursor;
Screen.Cursor := crHourGlass;
actSend.Enabled := False;
if not(dmMain.AllowedAction(rght_Messages_add) or
dmMain.AllowedAction(rght_Customer_full)) then
exit;
mmoLog.Visible := True;
mmoLog.Clear;
if cbMessType.Text = '' then
cbMessType.Value := 'SMS';
mes_t := cbMessType.Value;
itsEmail := mes_t.ToUpper.Contains('EMAIL');
// FReportLoaded := False;
// if itsEmail and VarIsNumeric(lcbReportAsPDF.KeyValue)
// then LoadReportBody;
try
with CustomersForm do
begin
if dbgCustomers.SelectedRows.Count > 0 then
begin
progress.Max := dbgCustomers.SelectedRows.Count;
for j := 0 to dbgCustomers.SelectedRows.Count - 1 do
begin
dbgCustomers.DataSource.DataSet.Bookmark :=
dbgCustomers.SelectedRows[j];
if not itsEmail then
SendMessage(mes_t)
else
SendEmailMessage;
end
end
else
begin
progress.Max := 1;
if not itsEmail then
SendMessage(mes_t)
else
SendEmailMessage;
end;
end;
finally
Screen.Cursor := crsr;
end;
actSend.Enabled := True;
if mmoLog.Lines.Count = 0 then
ModalResult := mrOk;
end;
procedure TSendMessagesForm.btnAddFileClick(Sender: TObject);
begin
if DlgFileOpen.Execute then
lvFiles.Items.Add.Caption := DlgFileOpen.FileName;
end;
procedure TSendMessagesForm.btnDeleteFileClick(Sender: TObject);
begin
if lvFiles.SelCount > 0 then
lvFiles.Selected.Delete;
end;
procedure TSendMessagesForm.cbMessTypeChange(Sender: TObject);
var
show: Boolean;
begin
show := False;
if not dsMessType.FieldByName('O_NUMERICFIELD').IsNull then
show := (dsMessType['O_NUMERICFIELD'] = 1);
pnlHead.Visible := show;
pnlReport.Visible := cbMessType.Text.Contains('EMAIL');
end;
procedure TSendMessagesForm.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (Shift = [ssCtrl]) and (Ord(Key) = VK_RETURN) then
actSendExecute(Sender);
end;
procedure TSendMessagesForm.FormResize(Sender: TObject);
begin
lvFiles.Columns[0].Width := lvFiles.Width - 15;
end;
procedure TSendMessagesForm.FormShow(Sender: TObject);
var
I: Integer;
val: TStringArray;
s: string;
begin
dsMessType.Open;
dsLetterTypes.Open;
dsTemplate.Open;
val := Explode(';', export_fields);
for I := 0 to Length(val) - 1 do
begin
pmMemo.Items.Add(NewItem(val[I], 0, False, True, miClick, 0,
'mi' + IntToStr(I)));
end;
if CustomersForm.dbgCustomers.SelectedRows.Count > 0 then
s := IntToStr(CustomersForm.dbgCustomers.SelectedRows.Count)
else
s := '1';
btnOk.Caption := btnOk.Caption + ' ( ' + s + ' ' + rsPiece + ')';
end;
function TSendMessagesForm.frxReportUserFunction(const MethodName: string;
var Params: Variant): Variant;
begin
Result := dmMain.frxReportUserFunction(MethodName, Params);
end;
procedure TSendMessagesForm.miClick(Sender: TObject);
begin
if (Sender is TMenuItem) then
(ActiveControl as TDBMemoEh).SelText :=
ReplaceStr((Sender as TMenuItem).Caption, '&', '');
end;
procedure TSendMessagesForm.mmoMessageChange(Sender: TObject);
begin
lbl1.Caption := Format(rsMSG_CharCount, [Length(mmoMessage.Text)]);
end;
procedure TSendMessagesForm.actInsertTmplateExecute(Sender: TObject);
begin
if not dsTemplate.Active then
begin
dsTemplate.Open;
exit;
end;
if not dsTemplate.FieldByName('O_CHARFIELD').IsNull then
mmoMessage.Lines.Add(dsTemplate['O_CHARFIELD']);
if not dsTemplate.FieldByName('O_NAME').IsNull then
edtHEAD.Text := dsTemplate['O_NAME'];
end;
procedure TSendMessagesForm.actSaveTemplateExecute(Sender: TObject);
begin
if Length(mmoMessage.Lines.Text) > 10 then
begin
if not dsTemplate.Active then
dsTemplate.Open;
dsTemplate.Insert;
dsTemplate['O_CHARFIELD'] := mmoMessage.Lines.Text;
if edtHEAD.Text <> '' then
dsTemplate['O_NAME'] := edtHEAD.Text
else
dsTemplate['O_NAME'] := Copy(mmoMessage.Lines.Text, 1, 10);
dsTemplate.Post;
dsTemplate.CloseOpen(True);
end;
//
end;
procedure TSendMessagesForm.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
if dsLetterTypes.Active then
dsLetterTypes.Close;
if dsTemplate.Active then
dsTemplate.Close;
if dsMessType.Active then
dsMessType.Close;
end;
procedure TSendMessagesForm.actDeleteTemplateExecute(Sender: TObject);
begin
if not dsTemplate.Active then
begin
dsTemplate.Open;
exit;
end;
if dsTemplate.RecordCount = 0 then
exit;
if MessageDlg('Удалить шаблон сообщения?', mtConfirmation, [mbYes, mbNo], 0) = mrYes
then
begin
dsTemplate.Delete;
end;
end;
procedure TSendMessagesForm.dbgTemplateDblClick(Sender: TObject);
begin
actInsertTmplate.Execute;
end;
procedure TSendMessagesForm.dsMessTypeAfterOpen(DataSet: TDataSet);
begin
if not dsMessType.FieldByName('O_NAME').IsNull then
cbMessType.Value := dsMessType['O_NAME']
end;
procedure TSendMessagesForm.LoadReportBody;
var
Stream: TStream;
begin
try
dmMain.fdsLoadReport.ParamByName('ID_REPORT').Value :=
lcbReportAsPDF.KeyValue;
dmMain.fdsLoadReport.Open;
if dmMain.fdsLoadReport.FieldByName('REPORT_BODY').Value <> NULL then
begin
Stream := TMemoryStream.Create;
try
TBlobField(dmMain.fdsLoadReport.FieldByName('REPORT_BODY'))
.SaveToStream(Stream);
Stream.Position := 0;
frxReport.LoadFromStream(Stream);
frxReport.FileName := GetTempDir() + CustomersForm.dsCustomers
['ACCOUNT_NO'] + '.' + dmMain.fdsLoadReport.FieldByName('REPORT_NAME')
.AsString + '.PDF';
FReportLoaded := True;
finally
Stream.Free;
end;
end;
finally
if dmMain.fdsLoadReport.Active then
dmMain.fdsLoadReport.Close;
end;
end;
procedure TSendMessagesForm.lvFilesDblClick(Sender: TObject);
begin
btnAddFile.Click;
end;
procedure TSendMessagesForm.InitEmailClient(emailClient: TEmailClient);
begin
emailClient.SmtpHost := dmMain.GetSettingsValue('SMTP');
emailClient.SmtpPort := dmMain.GetSettingsValue('SMTP_PORT');
emailClient.SmtpLogin := dmMain.GetSettingsValue('SMTP_LOGIN');
emailClient.SmtpPassword := dmMain.GetSettingsValue('SMTP_PASS');
emailClient.FromEmail := dmMain.GetSettingsValue('EMAIL');
emailClient.AuthType := dmMain.GetSettingsValue('SMTP_AUTH');
emailClient.SslType := dmMain.GetSettingsValue('SMTP_SSL');
if dmMain.GetSettingsValue('SMTP_2ME') <> '1' then
emailClient.CcEmail := ''
else
emailClient.CcEmail := dmMain.GetSettingsValue('EMAIL');
emailClient.Confirm := dmMain.GetSettingsValue('SMTP_CONF');
end;
end.
|
unit V_ADS;
interface
procedure errorIfOutOfRange(pos : integer);
procedure add(val : integer);
procedure getElementAt(pos : integer; var val : integer);
procedure setElementAt(pos : integer; val : integer);
procedure removeElementAt(pos : integer);
function size : integer;
function capacity : integer;
function isEmpty : boolean;
procedure init;
procedure disposeStack;
procedure reallocStack;
implementation
type
intArray = array [1..1] of integer;
VAR
arrPtr : ^intArray;
capacityCount : integer;
top : integer; (* index of top element *)
procedure init;
begin
if(arrPtr <> NIL) then begin
writeln('Can''t initialize non-empty stack!');
halt;
end;
top := 0;
capacityCount := 2;
GetMem(arrPtr, SIZEOF(integer) * capacityCount);
end;
procedure errorIfOutOfRange(pos : integer);
begin
if pos > top then begin
writeln('Pos out of range!');
halt;
end;
end;
procedure add(val : integer);
begin
if top >= capacityCount then
reallocStack;
inc(top);
(*$R-*)
arrPtr^[top] := val;
(*$R+*)
end;
procedure getElementAt(pos : integer; var val : integer);
begin
errorIfOutOfRange(pos);
(*$R-*)
val := arrPtr^[pos];
(*$R+*)
end;
procedure setElementAt(pos : integer; val : integer);
begin
errorIfOutOfRange(pos);
(*$R-*)
arrPtr^[pos] := val;
(*$R+*)
end;
procedure removeElementAt(pos : integer);
var
element : integer;
begin
errorIfOutOfRange(pos);
element := pos + 1;
while element <= top do begin
(*$R-*)
arrPtr^[element - 1] := arrPtr^[element];
(*$R+*)
inc(element);
end;
(*$R-*)
arrPtr^[top] := 0;
(*$R+*)
dec(top);
end;
function size : integer;
begin
size := top;
end;
function capacity : integer;
begin
capacity := capacityCount;
end;
function isEmpty : boolean;
begin
isEmpty := top = 0;
end;
procedure disposeStack;
begin
if arrPtr = NIL then begin
writeln('Can''t dispose a uninitialized stack!');
halt;
end;
freeMem(arrPtr, SIZEOF(integer) * capacityCount);
arrPtr := NIL;
end;
procedure reallocStack;
var
newArray : ^intArray;
i : integer;
begin
getMem(newArray, SIZEOF(INTEGER) * 2 * capacityCount);
for i := 1 to top do begin
(*$R-*)
newArray^[i] := arrPtr^[i];
(*$R+*)
end;
freeMem(arrPtr, SIZEOF(integer) * capacityCount);
capacityCount := 2 * capacityCount;
arrPtr := newArray;
end;
begin
arrPtr := NIL;
end.
|
{
$Project$
$Workfile$
$Revision$
$DateUTC$
$Id$
This file is part of the Indy (Internet Direct) project, and is offered
under the dual-licensing agreement described on the Indy website.
(http://www.indyproject.org/)
Copyright:
(c) 1993-2005, Chad Z. Hower and the Indy Pit Crew. All rights reserved.
}
{
$Log$
}
unit IdWebDAV;
//implements http://www.faqs.org/rfcs/rfc2518.html
{
general cleanup possibilities:
todo change embedded strings to consts
todo change depth param from infinity to -1? also string>integer?
}
interface
{$i IdCompilerDefines.inc}
uses
Classes,
IdHTTP;
const
Id_HTTPMethodPropFind = 'PROPFIND'; {do not localize}
Id_HTTPMethodPropPatch = 'PROPPATCH'; {do not localize}
Id_HTTPMethodOrderPatch = 'ORDERPATCH'; {do not localize}
Id_HTTPMethodSearch = 'SEARCH'; {do not localize}
Id_HTTPMethodMKCol = 'MKCOL'; {do not localize}
Id_HTTPMethodMove = 'MOVE'; {do not localize}
Id_HTTPMethodCopy = 'COPY'; {do not localize}
Id_HTTPMethodCheckIn = 'CHECKIN'; {do not localize}
Id_HTTPMethodCheckOut = 'CHECKOUT'; {do not localize}
Id_HTTPMethodUnCheckOut = 'UNCHECKOUT'; {do not localize}
Id_HTTPMethodLock = 'LOCK'; {do not localize}
Id_HTTPMethodUnLock = 'UNLOCK'; {do not localize}
Id_HTTPMethodReport = 'REPORT'; {do not localize}
Id_HTTPMethodVersion = 'VERSION-CONTROL'; {do not localize}
Id_HTTPMethodLabel = 'LABEL'; {do not localize}
Id_HTTPMethodMakeCol = 'MKCOL'; {Do not localize}
const
//casing is according to rfc
cTimeoutInfinite = 'Infinite'; {do not localize}
cDepthInfinity = 'infinity'; {do not localize}
type
TIdWebDAV = class(TIdHTTP)
public
procedure DAVCheckIn(const AURL, AComment: string);
procedure DAVCheckOut(const AURL: string; const AXMLQuery: TStream; const AComment: string);
procedure DAVCopy(const AURL, DURL: string; const AResponseContent: TStream; const AOverWrite: boolean = True; const ADepth: string = cDepthInfinity);
procedure DAVDelete(const AURL: string; const ALockToken: string);
procedure DAVLabel(const AURL: string; const AXMLQuery: TStream);
procedure DAVLock(const AURL: string; const AXMLQuery, AResponseContent: TStream; const ALockToken, ATags: string; const ATimeOut: string = cTimeoutInfinite; const AMustExist: Boolean = False; const ADepth: string = '0'); {do not localize}
procedure DAVMove(const AURL, DURL: string; const AResponseContent: TStream; const AOverWrite: Boolean = True; const ADepth: string = cDepthInfinity);
procedure DAVOrderPatch(const AURL: string; const AXMLQuery: TStream);
procedure DAVPropFind(const AURL: string; const AXMLQuery, AResponseContent: TStream; const ADepth: string = '0'; const ARangeFrom: Integer = -1; const ARangeTo: Integer = -1); {do not localize}
procedure DAVPropPatch(const AURL: string; const AXMLQuery, AResponseContent: TStream; const ADepth: string = '0'); {do not localize}
procedure DAVPut(const AURL: string; const ASource: TStream; const ALockToken: String);
procedure DAVReport(const AURL: string; const AXMLQuery, AResponseContent: TStream);
procedure DAVSearch(const AURL: string; const ARangeFrom, ARangeTo: Integer; const AXMLQuery, AResponseContent: TStream; const ADepth: string = '0'); {do not localize}
procedure DAVUnCheckOut(const AURL: String);
procedure DAVUnLock(const AURL: string; const ALockToken: string);
procedure DAVVersionControl(const AURL: string);
procedure DAVMakeCollection(const AURL: string);
end;
implementation
uses
IdGlobal, SysUtils;
procedure TIdWebDAV.DAVPropPatch(const AURL: string; const AXMLQuery, AResponseContent: TStream;
const ADepth: string);
begin
Request.CustomHeaders.Values['Depth'] := ADepth; {do not localize}
try
DoRequest(Id_HTTPMethodPropPatch, AURL, AXMLQuery, AResponseContent, []);
finally
Request.CustomHeaders.Values['Depth'] := ''; {do not localize}
end;
end;
procedure TIdWebDAV.DAVPropFind(const AURL: string; const AXMLQuery, AResponseContent: TStream;
const ADepth: string; const ARangeFrom: Integer; const ARangeTo: Integer);
begin
if ARangeTo > -1 then begin
Request.CustomHeaders.Values['Range'] := 'Rows=' + IntToStr(ARangeFrom) + '-' + IntToStr(ARangeTo); {do not localize}
end else begin
Request.CustomHeaders.Values['Range'] := ''; {do not localize}
end;
Request.CustomHeaders.Values['Depth'] := ADepth; {do not localize}
try
DoRequest(Id_HTTPMethodPropfind, AURL, AXMLQuery, AResponseContent, []);
finally
Request.CustomHeaders.Values['Depth'] := ''; {do not localize}
if ARangeTo > -1 then begin
Request.CustomHeaders.Values['Range'] := ''; {do not localize}
end;
end;
end;
procedure TIdWebDAV.DAVOrderPatch(const AURL: string; const AXMLQuery: TStream);
begin
DoRequest(Id_HTTPMethodOrderPatch, AURL, AXMLQuery, nil, []);
end;
procedure TIdWebDAV.DAVSearch(const AURL: string; const ARangeFrom, ARangeTo: Integer;
const AXMLQuery, AResponseContent: TStream; const ADepth: string);
begin
if ARangeTo > -1 then begin
Request.CustomHeaders.Values['Range'] := 'Rows=' + IntToStr(ARangeFrom) + '-' + IntToStr(ARangeTo); {do not localize}
end else begin
Request.CustomHeaders.Values['Range'] := ''; {do not localize}
end;
Request.CustomHeaders.Values['Depth'] := ADepth; {do not localize}
try
DoRequest(Id_HTTPMethodSearch, AURL, AXMLQuery, AResponseContent, []);
finally
Request.CustomHeaders.Values['Depth'] := ''; {do not localize}
if ARangeTo > -1 then begin
Request.CustomHeaders.Values['Range'] := ''; {do not localize}
end;
end;
end;
procedure TIdWebDAV.DAVMove(const AURL, DURL: string; const AResponseContent: TStream;
const AOverWrite: Boolean; const ADepth: string);
begin
if not AOverWrite then begin
Request.CustomHeaders.Values['Overwrite'] := 'F'; {do not localize}
end else begin
Request.CustomHeaders.Values['Overwrite'] := ''; {do not localize}
end;
Request.CustomHeaders.Values['Destination'] := DURL; {do not localize}
Request.CustomHeaders.Values['Depth'] := ADepth; {do not localize}
try
DoRequest(Id_HTTPMethodMove, AURL, nil, AResponseContent, []);
finally
Request.CustomHeaders.Values['Destination'] := ''; {do not localize}
if not AOverWrite then begin
Request.CustomHeaders.Values['Overwrite']; {do not localize}
end;
Request.CustomHeaders.Values['Depth'] := ''; {do not localize}
end;
end;
procedure TIdWebDAV.DAVCopy(const AURL, DURL: string; const AResponseContent: TStream;
const AOverWrite: Boolean; const ADepth: string);
begin
Request.CustomHeaders.Values['Destination'] := DURL; {do not localize}
Request.CustomHeaders.Values['Overwrite'] := iif(AOverWrite, 'T', 'F'); {do not localize}
Request.CustomHeaders.Values['Depth'] := ADepth; {do not localize}
try
DoRequest(Id_HTTPMethodCopy, AURL, nil, AResponseContent, []);
finally
Request.CustomHeaders.Values['Destination'] := ''; {do not localize}
Request.CustomHeaders.Values['Overwrite'] := ''; {do not localize}
Request.CustomHeaders.Values['Depth'] := ''; {do not localize}
end;
end;
procedure TIdWebDAV.DAVCheckIn(const AURL, AComment: string);
var
LXML: TMemoryStream;
s: string;
begin
DoRequest(Id_HTTPMethodCheckIn, AURL, nil, nil, []);
if AComment <> '' then
begin
s := '<?xml version="1.0" encoding="utf-8" ?>' + {do not localize}
'<propertyupdate xmlns:D="DAV:"><set><prop>' + {do not localize}
'<comment>' + AComment + '</comment></prop></set></propertyupdate>'; {do not localize}
LXML := TMemoryStream.Create;
try
WriteStringToStream(LXML, s, IndyUTF8Encoding);
LXML.Position := 0;
DoRequest(Id_HTTPMethodPropPatch, AURL, LXML, nil, []);
finally
LXML.Free;
end;
end;
end;
procedure TIdWebDAV.DAVCheckOut(const AURL: String; const AXMLQuery: TStream; const AComment: String);
var
LXML: TMemoryStream;
s: string;
begin
DoRequest(Id_HTTPMethodCheckOut, AURL, AXMLQuery, nil, []);
if AComment <> '' then
begin
s := '<?xml version="1.0" encoding="utf-8" ?>' + {do not localize}
'<propertyupdate xmlns:D="DAV:"><set><prop>' + {do not localize}
'<comment>' + AComment + '</comment></prop></set></propertyupdate>'; {do not localize}
LXML := TMemoryStream.Create;
try
WriteStringToStream(LXML, s, IndyUTF8Encoding);
LXML.Position := 0;
DoRequest(Id_HTTPMethodPropPatch, AURL, LXML, nil, []);
finally
LXML.Free;
end;
end;
end;
procedure TIdWebDAV.DAVUnCheckOut(const AURL: string);
begin
DoRequest(Id_HTTPMethodUnCheckOut, AURL, nil, nil, []);
end;
procedure TIdWebDAV.DAVLock(const AURL: string; const AXMLQuery, AResponseContent: TStream;
const ALockToken, ATags: string; const ATimeOut: string; const AMustExist: Boolean;
const ADepth: string);
begin
//NOTE - do not specify a LockToken and Tags value. If both exist then only
//LockToken will be used. If you wish to use LockToken together with other
//tags then concatenate and send via Tags value.
//Also note that specifying the lock token in a lock request facilitates
//a lock refresh
Request.CustomHeaders.Values['Timeout'] := ATimeOut; {do not localize}
if AMustExist then
begin
Request.CustomHeaders.Values['If-Match'] := '*'; {do not localize}
Request.CustomHeaders.Values['If-None-Match'] := ''; {do not localize}
end else
begin
Request.CustomHeaders.Values['If-Match'] := ''; {do not localize}
Request.CustomHeaders.Values['If-None-Match'] := '*'; {do not localize}
end;
Request.CustomHeaders.Values['Depth'] := ADepth; {do not localize}
if ALockToken <> '' then begin
Request.CustomHeaders.Values['If'] := '(<'+ALockToken+'>)'; {do not localize}
end
else if ATags <> '' then begin
Request.CustomHeaders.Values['If'] := '('+ATags+')'; {do not localize}
end else begin
Request.CustomHeaders.Values['If'] := ''; {do not localize}
end;
try
DoRequest(Id_HTTPMethodLock, AURL, AXMLQuery, AResponseContent, []);
finally
Request.CustomHeaders.Values['Timeout'] := ''; {do not localize}
Request.CustomHeaders.Values['If-Match'] := ''; {do not localize}
Request.CustomHeaders.Values['If-None-Match'] := ''; {do not localize}
Request.CustomHeaders.Values['Depth'] := ''; {do not localize}
Request.CustomHeaders.Values['If'] := ''; {do not localize}
end;
end;
procedure TIdWebDAV.DAVUnLock(const AURL: string; const ALockToken: string);
begin
Request.CustomHeaders.Values['Lock-Token'] := '<'+ALockToken+'>'; {do not localize}
try
DoRequest(Id_HTTPMethodUnLock, AURL, nil, nil, []);
finally
Request.CustomHeaders.Values['Lock-Token'] := ''; {do not localize}
end;
end;
procedure TIdWebDAV.DAVReport(const AURL: string; const AXMLQuery, AResponseContent: TStream);
begin
DoRequest(Id_HTTPMethodReport, AURL, AXMLQuery, AResponseContent, []);
end;
procedure TIdWebDAV.DAVVersionControl(const AURL: string);
begin
DoRequest(Id_HTTPMethodVersion, AURL, nil, nil, []);
end;
procedure TIdWebDAV.DAVLabel(const AURL: string; const AXMLQuery: TStream);
begin
DoRequest(Id_HTTPMethodLabel, AURL, AXMLQuery, nil, []);
end;
procedure TIdWebDAV.DAVPut(const AURL: string; const ASource: TStream; const ALockToken: String);
begin
if ALockToken <> '' then begin
Request.CustomHeaders.Values['If'] := '(<'+ALockToken+'>)'; {do not localize}
end else begin
Request.CustomHeaders.Values['If'] := ''; {do not localize}
end;
try
inherited Put(AURL, ASource, TStream(nil));
finally
if ALockToken <> '' then begin
Request.CustomHeaders.Values['If'] := ''; {do not localize}
end;
end;
end;
procedure TIdWebDAV.DAVDelete(const AURL: string; const ALockToken: string);
begin
if ALockToken <> '' then begin
Request.CustomHeaders.Values['If'] := '(<'+ALockToken+'>)'; {do not localize}
end else begin
Request.CustomHeaders.Values['If'] := ''; {do not localize}
end;
try
inherited Delete(AURL);
finally
if ALockToken <> '' then begin
Request.CustomHeaders.Values['If'] := ''; {do not localize}
end;
end;
end;
procedure TIdWebDAV.DAVMakeCollection(const AURL: string);
begin
DoRequest(Id_HTTPMethodMakeCol, AURL, nil, nil, []);
end;
end.
|
{ *********************************************************************************** }
{ * CryptoLib Library * }
{ * Copyright (c) 2018 - 20XX Ugochukwu Mmaduekwe * }
{ * Github Repository <https://github.com/Xor-el> * }
{ * Distributed under the MIT software license, see the accompanying file LICENSE * }
{ * or visit http://www.opensource.org/licenses/mit-license.php. * }
{ * Acknowledgements: * }
{ * * }
{ * Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring * }
{ * development of this library * }
{ * ******************************************************************************* * }
(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *)
unit ClpPascalCoinECIESKdfBytesGenerator;
{$I ..\..\Include\CryptoLib.inc}
interface
uses
SysUtils,
ClpIDigest,
ClpBaseKdfBytesGenerator,
ClpIDerivationParameters,
ClpIKdfParameters,
ClpIPascalCoinECIESKdfBytesGenerator,
ClpCryptoLibTypes;
resourcestring
SOutputBufferTooSmall = 'Output Buffer too Small';
SKDFParameterNotFound = 'KDF Parameters Required For KDF Generator';
SHashCannotNotProduceSufficientData =
'Specified Hash Cannot Produce Sufficient Data for the Specified Operation.';
type
/// <summary>
/// <para>
/// KDF generator for compatibility with existing PascalCoin Implementation
/// </para>
/// </summary>
TPascalCoinECIESKdfBytesGenerator = class(TBaseKdfBytesGenerator,
IPascalCoinECIESKdfBytesGenerator)
strict protected
function GetDigest(): IDigest; override;
public
/// <summary>
/// Construct a PascalCoin compatible bytes generator.
/// </summary>
/// <param name="digest">
/// the digest to be used as the source of derived keys.
/// </param>
constructor Create(const digest: IDigest);
procedure Init(const parameters: IDerivationParameters); override;
/// <summary>
/// return the underlying digest.
/// </summary>
property digest: IDigest read GetDigest;
/// <summary>
/// fill len bytes of the output buffer with bytes generated from the
/// derivation function.
/// </summary>
/// <exception cref="EArgumentCryptoLibException">
/// if the size of the request will cause an overflow.
/// </exception>
/// <exception cref="EDataLengthCryptoLibException">
/// if the out buffer is too small.
/// </exception>
function GenerateBytes(const output: TCryptoLibByteArray;
outOff, length: Int32): Int32; override;
end;
implementation
{ TPascalCoinECIESKdfBytesGenerator }
constructor TPascalCoinECIESKdfBytesGenerator.Create(const digest: IDigest);
begin
Inherited Create(0, digest);
end;
function TPascalCoinECIESKdfBytesGenerator.GenerateBytes
(const output: TCryptoLibByteArray; outOff, length: Int32): Int32;
var
outLen: Int32;
oBytes: Int64;
temp: TCryptoLibByteArray;
begin
if ((System.length(output) - length) < outOff) then
begin
raise EDataLengthCryptoLibException.CreateRes(@SOutputBufferTooSmall);
end;
oBytes := length;
outLen := Fdigest.GetDigestSize;
if (oBytes > outLen) then
begin
raise EDataLengthCryptoLibException.CreateRes
(@SHashCannotNotProduceSufficientData);
end;
System.SetLength(temp, Fdigest.GetDigestSize);
Fdigest.BlockUpdate(Fshared, 0, System.length(Fshared));
Fdigest.DoFinal(temp, 0);
System.Move(temp[0], output[outOff], length * System.SizeOf(Byte));
Fdigest.Reset();
result := oBytes;
end;
function TPascalCoinECIESKdfBytesGenerator.GetDigest: IDigest;
begin
result := Fdigest;
end;
procedure TPascalCoinECIESKdfBytesGenerator.Init(const parameters
: IDerivationParameters);
var
Lparameters: IDerivationParameters;
p1: IKdfParameters;
begin
Lparameters := parameters;
if Supports(Lparameters, IKdfParameters, p1) then
begin
Fshared := p1.GetSharedSecret();
Fiv := p1.GetIV();
end
else
begin
raise EArgumentCryptoLibException.CreateRes(@SKDFParameterNotFound);
end;
end;
end.
|
unit IdTypes;
interface
uses classes;
type
TGraphInfo=record
GraphName:String;
VertexCol:Cardinal;
Offx,Offy,Offz:smallint;
end;
PGraphInfo=^TGraphInfo;
TMapIdInfo=record
Defined:Cardinal;
IdType:Cardinal;
Reversed:Cardinal;
Modx,Mody:longint;
MinimapColor:Cardinal;
MiniMapTexPx,
MiniMapTexPy,
MiniMapTexPx2,
MiniMapTexPy2:single; //minimapTexturing coordinate
LightInfo:Cardinal; //0:no shadow 2:need to draw dynamic shadow 4:this object cast light 8:this object block light
ColorFx:Cardinal;
GraphCount:Cardinal;
GraphInfo:TList; //list of TGraphInfo
end;
TSoundInfo=record
SoundName:string;
PitchDev:single;
end;
PSoundInfo=^TSoundInfo;
TFrame=record
SpriteName:string;
Offx,Offy:smallint;
end;
PFrame=^TFrame;
TFrameList=record
Reversed:Cardinal;
GraphCount:Cardinal;
FrameList:TList; //list of TFrame
end;
TDirectionAnim=array[0..7]of TFrameList;
TMonsterSkinInfo=record
SkinName:string;
SkinId:word;
VertexColor:cardinal;
ColorFx:Cardinal;
AnimationDelay:single; //in seconds
MonsterSize:single; //shrinkening or growing factor 1 = normal size
Walk,Attack:TDirectionAnim;
Death:TFrameList;
AtkSoundCount:cardinal;
AtkSounds:TList; //list of TSoundInfo
HitSoundCount:cardinal;
HitSounds:TList; //list of TSoundInfo
DieSoundCount:cardinal;
DieSounds:TList; //list of TSoundInfo
IdleSoundCount:cardinal;
IdleSounds:TList; //list of TSoundInfo
end;
PMonsterSkinInfo=^TMonsterSkinInfo;
//NOTE : We could use the previous structure for puppet also since it's very very similar
TPuppetSkinPartInfo=record
SkinName:string;
SkinId:word; //it is the Appearance in fact (same for male and female)
//Last bit is set to 1 for a female puppet appearance
Female:boolean;
VertexColor:cardinal;
ColorFx:Cardinal;
AnimationDelay:single;
Walk,Attack,Range:TDirectionAnim;
Death:TFrameList;
end;
PPuppetSkinPartInfo=^TPuppetSkinPartInfo;
TItemSkinInfo=record
SkinName:string;
SkinId:word;
SkinType:Cardinal;
MouseCursor:Cardinal;
ColorFx:cardinal;
VertexColor:cardinal;
AnimationDelay:single;
OpenSound:string;
CloseSound:string;
GraphCount:Cardinal;
GraphInfo:TList; //list of TFrame
end;
PItemSkinInfo=^TItemSkinInfo;
implementation
end.
|
unit TrackingHistoryUnit;
interface
uses
REST.Json.Types, System.Generics.Collections,
Generics.Defaults,
JSONNullableAttributeUnit,
NullableBasicTypesUnit;
type
/// <summary>
/// Tracking History
/// </summary>
/// <remarks>
/// https://github.com/route4me/json-schemas/blob/master/TrackingHistory.dtd
/// </remarks>
TTrackingHistory = class
private
[JSONName('s')]
[Nullable]
FSpeed: NullableString;
[JSONName('lt')]
[Nullable]
FLatitude: NullableString;
[JSONName('lg')]
[Nullable]
FLongitude: NullableString;
[JSONName('d')]
[Nullable]
FD: NullableString;
[JSONName('m')]
[Nullable]
FM: NullableString;
[JSONName('ts')]
[Nullable]
FTimeStamp: NullableString;
[JSONName('src')]
[Nullable]
FSrc: NullableString;
[JSONName('ts_friendly')]
[Nullable]
FTimeStampFriendly: NullableString;
public
/// <remarks>
/// Constructor with 0-arguments must be and be public.
/// For JSON-deserialization.
/// </remarks>
constructor Create; overload;
function Equals(Obj: TObject): Boolean; override;
/// <summary>
/// Speed at the time of the location transaction event
/// </summary>
property Speed: NullableString read FSpeed write FSpeed;
/// <summary>
/// Latitude at the time of the location transaction event
/// </summary>
property Latitude: NullableString read FLatitude write FLatitude;
/// <summary>
/// Longitude at the time of the location transaction event
/// </summary>
property Longitude: NullableString read FLongitude write FLongitude;
/// <summary>
/// Direction/Heading at the time of the location transaction event
/// </summary>
property Direction: NullableString read FD write FD;
/// <summary>
/// The original timestamp in unix timestamp format at the moment location transaction event
/// </summary>
property TimeStamp: NullableString read FTimeStamp write FTimeStamp;
/// <summary>
///
/// </summary>
property M: NullableString read FM;
/// <summary>
///
/// </summary>
property Src: NullableString read FSrc;
/// <summary>
/// The original timestamp in a human readable timestamp format at the moment location transaction event
/// </summary>
property TimeStampFriendly: NullableString read FTimeStampFriendly write FTimeStampFriendly;
end;
TTrackingHistoryArray = TArray<TTrackingHistory>;
TTrackingHistoryList = TObjectList<TTrackingHistory>;
function SortTrackingHistory(TrackingHistories: TTrackingHistoryArray): TTrackingHistoryArray;
implementation
function SortTrackingHistory(TrackingHistories: TTrackingHistoryArray): TTrackingHistoryArray;
begin
SetLength(Result, Length(TrackingHistories));
if Length(TrackingHistories) = 0 then
Exit;
TArray.Copy<TTrackingHistory>(TrackingHistories, Result, Length(TrackingHistories));
TArray.Sort<TTrackingHistory>(Result, TComparer<TTrackingHistory>.Construct(
function (const History1, History2: TTrackingHistory): Integer
begin
Result := History1.Latitude.Compare(History2.Latitude);
if (Result = 0) then
Result := History1.Longitude.Compare(History2.Longitude);
end));
end;
{ TTrackingHistory }
constructor TTrackingHistory.Create;
begin
FSpeed := NullableString.Null;
FLatitude := NullableString.Null;
FLongitude := NullableString.Null;
FD := NullableString.Null;
FTimeStamp := NullableString.Null;
FTimeStampFriendly := NullableString.Null;
FM := NullableString.Null;
FSrc := NullableString.Null;
end;
function TTrackingHistory.Equals(Obj: TObject): Boolean;
var
Other: TTrackingHistory;
begin
Result := False;
if not (Obj is TTrackingHistory) then
Exit;
Other := TTrackingHistory(Obj);
Result :=
(FSpeed = Other.FSpeed) and
(FLatitude = Other.FLatitude) and
(FLongitude = Other.FLongitude) and
(FD = Other.FD) and
(FM = Other.FM) and
(FSrc = Other.FSrc) and
(FTimeStamp = Other.FTimeStamp) and
(FTimeStampFriendly = Other.FTimeStampFriendly);
end;
end.
|
unit IniClasses;
interface
uses
SysUtils, Classes;
const
iniBOOLTRUE = '1';
const
tidGeneral = 'General';
tidInherits = 'inherits';
tidName = 'Name';
tidId = 'Id';
type
TIniClass =
class
public
constructor Create(const aPath : string; aId : integer);
constructor Open(const aPath : string);
destructor Destroy; override;
private
fClassName : string;
fPath : string;
fSections : TStringList;
fParents : TStringList;
fCurSection : string;
private
procedure ReadAnsestors(const aClassName : string; Properties : TStringList);
procedure ReadClassProperties(ClassName : string; Properties : TStringList);
procedure DoGetSection(Name : string; Properties : TStringList);
public
function ReadString(const Section, Name : string; DefValue : string ) : string;
function ReadInteger(const Section, Name : string; DefValue : integer) : integer;
function ReadBool(const Section, Name : string; DefValue : boolean) : boolean;
procedure ReadAllSections;
private
function GetSection(const Section : string) : TStringList;
public
property Sections[const Section : string] : TStringList read GetSection;
property SectionList : TStringList read fSections;
end;
implementation
uses
IniFiles, CompStringsParser;
function GetActualClassName(const aPath, aClassId : string) : string;
var
Search : TSearchRec;
begin
try
if FindFirst(aPath + '*.' + aClassId + '.*.ini', faArchive, Search) = 0
then result := Search.Name
else result := aClassId;
finally
FindClose(Search);
end;
end;
constructor TIniClass.Create(const aPath : string; aId : integer);
begin
inherited Create;
fPath := aPath;
fClassName := GetActualClassName(aPath, IntToStr(aId));
fSections := TStringList.Create;
fSections.Sorted := true;
fSections.Duplicates := dupIgnore;
end;
constructor TIniClass.Open(const aPath : string);
begin
inherited Create;
fPath := ExtractFilePath(aPath);
fClassName := ExtractFileName(aPath);
fSections := TStringList.Create;
fSections.Sorted := true;
fSections.Duplicates := dupIgnore;
end;
destructor TIniClass.Destroy;
var
i : integer;
begin
for i := 0 to pred(fSections.count) do
fSections.Objects[i].Free;
fSections.Free;
fParents.Free;
inherited;
end;
procedure TIniClass.ReadAnsestors(const aClassName : string; Properties : TStringList);
var
IniFile : TIniFile;
inh : string;
aux : string;
p : integer;
auxSect : TStringList;
begin
if fParents.IndexOf(aClassName) = -1
then fParents.Add(aClassName);
IniFile := TIniFile.Create(fPath + aClassName);
try
try
inh := IniFile.ReadString(tidGeneral, tidInherits, '');
auxSect := TStringList.Create;
IniFile.ReadSections(auxSect);
fSections.AddStrings(auxSect);
auxSect.Free;
finally
IniFile.Free;
end;
p := length(inh);
if p > 0
then
begin
aux := GetPrevStringUpTo(inh, p, ',');
while aux <> '' do
begin
ReadAnsestors(trim(aux) + '.ini', Properties);
dec(p);
aux := GetPrevStringUpTo(inh, p, ',');
end;
end;
except
end;
end;
procedure TIniClass.ReadClassProperties(ClassName : string; Properties : TStringList);
var
IniFile : TIniFile;
i : integer;
NewSect : TStringList;
begin
IniFile := TIniFile.Create(fPath + ClassName);
try
try
if fCurSection <> ''
then IniFile.ReadSectionValues(fCurSection, Properties)
else
for i := 0 to pred(fSections.Count) do
if fSections.Objects[i] <> nil
then IniFile.ReadSectionValues(fSections[i], TStringList(fSections.Objects[i]))
else
begin
NewSect := TStringList.Create;
IniFile.ReadSectionValues(fSections[i], NewSect);
fSections.Objects[i] := NewSect;
end;
finally
IniFile.Free;
end;
except
end;
end;
procedure TIniClass.DoGetSection(Name : string; Properties : TStringList);
var
i : integer;
begin
fCurSection := Name;
if fParents = nil
then
begin
fParents := TStringList.Create;
ReadAnsestors(fClassName, Properties);
end;
for i := pred(fParents.Count) downto 0 do
ReadClassProperties(fParents[i], Properties);
fCurSection := '';
end;
function TIniClass.ReadString(const Section, Name : string; DefValue : string) : string;
var
aux : string;
begin
aux := GetSection(lowercase(Section)).Values[Name];
if aux <> ''
then result := aux
else result := DefValue;
end;
function TIniClass.ReadInteger(const Section, Name : string; DefValue : integer) : integer;
var
aux : string;
begin
aux := GetSection(lowercase(Section)).Values[Name];
if aux = ''
then result := DefValue
else
try
result := StrToInt(aux);
except
result := DefValue;
end;
end;
function TIniClass.ReadBool(const Section, Name : string; DefValue : boolean) : boolean;
var
aux : string;
begin
aux := GetSection(lowercase(Section)).Values[Name];
if aux = ''
then result := DefValue
else result := aux = iniBOOLTRUE;
end;
procedure TIniClass.ReadAllSections;
begin
DoGetSection('', nil);
end;
function TIniClass.GetSection(const Section : string) : TStringList;
var
Sect : TStringList;
index : integer;
begin
index := fSections.IndexOf(lowercase(Section));
if index <> -1
then
begin
Sect := TStringList(fSections.Objects[index]);
if Sect = nil
then
begin
Sect := TStringlist.Create;
fSections.Objects[index] := Sect;
DoGetSection(Section, Sect);
end
end
else
begin
Sect := TStringlist.Create;
fSections.AddObject(lowercase(Section), Sect);
DoGetSection(Section, Sect);
end;
result := Sect;
end;
end.
|
unit D_DateNumberEditor;
{ $Id: D_DateNumberEditor.pas,v 1.32 2016/08/11 11:37:09 lukyanets Exp $ }
interface
{$I arDefine.inc}
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, ExtCtrls, Mask,
k2Interfaces, k2Tags,
l3Date,
DT_Const, DT_Types, DT_DictTypes,
BottomBtnDlg, vtCombo, vtDateEdit,
l3Variant
;
type
TDateNumEditorDlg = class(TBottomBtnDlg)
Bevel3: TBevel;
Bevel2: TBevel;
Bevel1: TBevel;
Label1: TLabel;
lblDate: TLabel;
lblNumber: TLabel;
edtDate: TvtDateEdit;
cbDNType: TComboBox;
edtNumber: TEdit;
cbMOJNOTREG: TCheckBox;
procedure cbDNTypeChange(Sender: TObject);
procedure edtNumberChange(Sender: TObject);
procedure edtDateChange(Sender: TObject);
procedure cbMOJNOTREGClick(Sender: TObject);
procedure OKClick(Sender: TObject);
procedure edtDateExit(Sender: TObject);
private
{ Private declarations }
//fDocFam : TdaFamilyID;
lSaveDNType : TDNType; //для запоминания последнего обработанного переключения. Использутся для настройки контролов ввода параметров
fSaveEdtNumberText : string;
fSaveEdtDate : TStDate;
procedure CheckFlagedMOJNOTREG;
function pm_GetCurDNType: TDNType;
procedure pm_SetCurDNType(const Value: TDNType);
protected
property CurDNType: TDNType read pm_GetCurDNType write pm_SetCurDNType;
public
function Execute({aDocFam : TdaFamilyID;} aRec : Tl3Tag; WasEmpty : Boolean) : Boolean;
end;
function GetAttrDateNum(aRec : Tl3Tag; aRecEmpty : Boolean = False) : boolean;
implementation
{$R *.DFM}
uses
l3Base,
l3String,
l3MinMax,
vtDialogs,
//DictsSup,
DocAttrUtils,
StrShop,
AddrSup,
daSchemeConsts,
DT_Serv,
DT_LinkServ,
Dt_ReNum, dt_DictConst;
{TDNDictRec = Record
ID : Longint;
Date : TStDate;
Num : TNumberStr;
Typ : TDNType;
Coment : Array[1..70] of Char;
end;
}
function GetAttrDateNum(aRec : Tl3Tag; aRecEmpty : Boolean = False) : boolean;
begin
With TDateNumEditorDlg.Create(nil) do
try
Result := Execute(aRec, aRecEmpty);
finally
Free;
end;
end;
function TDateNumEditorDlg.Execute(aRec : Tl3Tag; WasEmpty : Boolean) : Boolean;
var
lDocID : TDocID;
lRDocID : TDocID;
lSubID : TSubID;
begin
GetDNTypeList(cbDNType.Items);
cbDNType.Items.Delete(0); // dnDoc - не нужен
//LoadStringList(cbDNType.Items, NumOfDNStr, sidFirstDataNumRec);
//fDocFam := aDocFam;
if not WasEmpty then
with aRec do
begin
//if Date <> BlankDate then
edtDate.StDate := IntA[k2_tiStart];
fSaveEdtDate := edtDate.StDate;
CurDNType := TDNType(IntA[k2_tiType]);
lSaveDNType := CurDNType;
if CurDNType = dnChangerDate then
begin
lblNumber.Caption := 'Ссылка на изменяющий';
with Attr[k2_tiLinkAddress] do
if IsValid then
begin
lDocID := IntA[k2_tiDocID];
if lDocID > 0 then
lDocID := LinkServer(CurrentFamily).Renum.GetExtDocID(lDocID);
if lDocID > 0 then
edtNumber.Text := format('%d.%d', [lDocID, IntA[k2_tiSubID]]);
end;
end
else
begin
lblNumber.Caption := 'Номер';
edtNumber.Text := StrA[k2_tiNumber];
end;
end
else
begin
//aRec.ID := cUndefDictID;
cbDNType.ItemIndex := 0;
end;
cbDNTypeChange(Self);
edtNumberChange(Self);
Result := ShowModal = mrOk;
If Result then
with aRec do
begin
AttrW[k2_tiName, nil] := nil;
IntA[k2_tiStart] := StDateToDemon(edtDate.StDate);
IntA[k2_tiType] := Ord(CurDNType);
AttrW[k2_tiLinkAddress, nil] := nil;
if CurDNType = dnChangerDate then
begin
StrToDocAddr(edtNumber.Text, lDocID, lSubID);
if lDocID < 0 then lDocID := 0;
if lSubID < 0 then lSubID := 0;
if lDocID > 0 then
lRDocID := Max(LinkServer(CurrentFamily).Renum.ConvertToRealNumber(lDocID), 0)
else
lRDocID := 0;
if lRDocID = 0 then
lSubID := 0;
with cAtom(k2_tiLinkAddress) do
begin
IntA[k2_tiDocID] := lRDocID;
IntA[k2_tiSubID] := lSubID;
end;
StrA[k2_tiNumber] := '';
end
else
begin
StrA[k2_tiNumber] := l3MakeSimpleANSIStr(edtNumber.Text);
end
end; //with aRec do
end;
procedure TDateNumEditorDlg.cbDNTypeChange(Sender: TObject);
begin
if lSaveDNType = CurDNType then Exit;
cbMOJNOTREG.Visible := CurDNType = dnMU;
if CurDNType = dnChangerDate then
begin
lblNumber.Caption := 'Ссылка на изменяющий';
edtNumber.Clear;
end
else
begin
lblNumber.Caption := 'Номер';
if lSaveDNType = dnChangerDate then
edtNumber.Text := fSaveEdtNumberText;
//edtNumber.Clear;
end;
if CurDNType in [dnLawCaseNum{, dnAddNum}] then
begin
edtDate.Enabled := False;
lblDate.Enabled := False;
edtDate.Clear;
end
else
begin
edtDate.Enabled := True;
lblDate.Enabled := True;
edtDate.StDate := fSaveEdtDate;
end;
CheckFlagedMOJNOTREG;
lSaveDNType := CurDNType;
end;
type
TButtonControlHack = class(TButtonControl)
public
property ClicksDisabled;
end;
procedure TDateNumEditorDlg.CheckFlagedMOJNOTREG;
begin
TButtonControlHack(cbMOJNOTREG).ClicksDisabled := True;
try
cbMOJNOTREG.Checked := (CurDNType = dnMU) and
(edtNumber.Text = '') and (edtDate.Date = NullDate);
finally
TButtonControlHack(cbMOJNOTREG).ClicksDisabled := False;
end;
end;
procedure TDateNumEditorDlg.edtNumberChange(Sender: TObject);
begin
CheckFlagedMOJNOTREG;
if CurDNType <> dnChangerDate then
fSaveEdtNumberText := edtNumber.Text;
end;
procedure TDateNumEditorDlg.edtDateExit(Sender: TObject);
begin
inherited;
fSaveEdtDate := edtDate.StDate;
end;
procedure TDateNumEditorDlg.edtDateChange(Sender: TObject);
begin
CheckFlagedMOJNOTREG;
end;
procedure TDateNumEditorDlg.cbMOJNOTREGClick(Sender: TObject);
begin
If cbMOJNOTREG.Checked
then
begin
edtNumber.Clear;
edtDate.Clear;
end;
end;
procedure TDateNumEditorDlg.OKClick(Sender: TObject);
begin
ModalResult := mrOK;
end;
function TDateNumEditorDlg.pm_GetCurDNType: TDNType;
begin
Result := TDNType(cbDNType.ItemIndex + 1);
end;
procedure TDateNumEditorDlg.pm_SetCurDNType(const Value: TDNType);
begin
cbDNType.ItemIndex := Ord(Value) - 1;
end;
end.
|
unit FormTextForm;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls;
type
TformText = class(TForm)
memoOut: TMemo;
pBar: TPanel;
btnResource: TButton;
btnCurrent: TButton;
btnPanel: TButton;
procedure btnResourceClick(Sender: TObject);
procedure btnCurrentClick(Sender: TObject);
procedure btnPanelClick(Sender: TObject);
private
{ Private declarations }
public
procedure ConvertAndShow (aStream: TStream);
end;
var
formText: TformText;
implementation
{$R *.DFM}
procedure TformText.btnResourceClick(Sender: TObject);
var
ResStr: TResourceStream;
begin
ResStr := TResourceStream.Create(
hInstance, 'TFORMTEXT', RT_RCDATA);
try
ConvertAndShow (ResStr);
finally
ResStr.Free
end;
end;
procedure TformText.btnCurrentClick(Sender: TObject);
var
MemStr: TStream;
begin
MemStr := TMemoryStream.Create;
try
MemStr.WriteComponent (Self);
ConvertAndShow (MemStr);
finally
MemStr.Free
end;
end;
procedure TformText.ConvertAndShow (aStream: TStream);
var
ConvStream: TStream;
begin
aStream.Position := 0;
ConvStream := TMemoryStream.Create;
try
ObjectBinaryToText (aStream, ConvStream);
ConvStream.Position := 0;
MemoOut.Lines.LoadFromStream (ConvStream);
finally
ConvStream.Free
end;
end;
procedure TformText.btnPanelClick(Sender: TObject);
var
MemStr: TStream;
begin
MemStr := TMemoryStream.Create;
try
MemStr.WriteComponent (pBar);
ConvertAndShow (MemStr);
finally
MemStr.Free
end;
end;
end.
|
unit UseList;
{$ifdef fpc}
{$mode delphi}
{$endif}
interface
uses SysUtils, Classes, tfNumerics;
// ListSize must be a power of 2
function DLog(const Value, Base, Modulo: BigInteger;
ListSize: Integer = 1024 * 1024): Int64;
implementation
type
PData = ^TData;
TData = record
Index: Integer;
Value: BigInteger;
end;
function ItemCompare(P1, P2: Pointer): Integer;
begin
Result:= BigInteger.Compare(PData(P1).Value, PData(P2).Value);
end;
function ValueExists(List: TList; Acc: BigInteger): Integer;
var
L, H, I, C: Integer;
begin
Result:= -1;
L:= 0;
H:= List.Count - 1;
while L <= H do begin
I:= (L + H) shr 1;
C:= BigInteger.Compare(PData(List[I]).Value, Acc);
if C < 0 then L:= I + 1
else begin
H:= I - 1;
if C = 0 then begin
Result:= PData(List[I]).Index;
Exit;
{if List.Duplicates <> dupAccept then} L := I;
end;
end;
end;
end;
function DLog(const Value, Base, Modulo: BigInteger;
ListSize: Integer): Int64;
var
List: TList;
Factor, Acc: BigInteger;
I, J: Integer;
P: PData;
begin
Assert(Base > 1);
if Value = 1 then begin
Result:= 0;
Exit;
end;
// todo: BigInteger
Factor:= BigInteger.ModInverse(Base, Modulo);
Assert((Base * Factor) mod Modulo = 1, 'ModInverse');
List:= TList.Create;
try
Acc:= Value;
for I:= 0 to ListSize - 1 do begin
New(P);
P.Index:= I;
P.Value:= Acc;
List.Add(P);
Acc:= (Acc * Factor) mod Modulo;
end;
List.Sort(@ItemCompare);
// todo: BigInteger
Factor:= BigInteger.ModPow(Base, ListSize, Modulo);
Acc:= 1;
for I:= 0 to ListSize - 1 do begin // 2^20 - 1
J:= ValueExists(List, Acc);
if J >= 0 then begin
Result:= I;
Result:= Result * ListSize + J;
Exit;
end;
Acc:= (Acc * Factor) mod Modulo;
// if I mod 1000 = 0 then Writeln(I);
end;
raise Exception.Create('DLog failed');
finally
for I:= 0 to ListSize - 1 do begin
Dispose(PData(List[I]));
end;
List.Free;
end;
end;
end.
|
unit akTotalLog;
interface
uses Windows, SysUtils;
type
ELoggedAssertion = class(Exception);
TTotalLog = class
private
fIsLogging: Boolean;
fFileName: string;
fIsDetailed: Boolean;
protected
procedure logdirect(str: string);
function IsDetailedLog(fn: string): boolean;
public
property IsLogging: Boolean read fIsLogging;
property IsDetailed: Boolean read fIsDetailed;
property FileName: string read fFileName;
constructor Create(createlog: Boolean); overload;
constructor Create(fFileN: string; createlog: Boolean); overload;
destructor Destroy; override;
procedure logf(id: LongWord; const form: string; const Args: array of const);
procedure log(id: LongWord; const str: string; comment: string = '');
procedure logd(id: LongWord; const str: string; comment: string = '');
procedure lassert(id: LongWord; exp: Boolean; comment: string = ''; raiseEx: Boolean = true);
function IsBadStr(id: LongWord; Str: PChar; Max: Integer; comment: string): Boolean;
function IsBadRPtr(id: LongWord; Str: Pointer; Size: Integer; comment: string): Boolean;
function IsBadWPtr(id: LongWord; Str: Pointer; Size: Integer; comment: string): Boolean;
procedure ShowLog;
end;
var lg: TTotalLog;
implementation
uses comobj, akFileUtils, akTotalLogView;
{ TTotalLog }
constructor TTotalLog.Create(fFileN: string; createlog: Boolean);
begin
inherited Create;
fFileName := fFileN;
if createlog then CreateFileIfNotExists(fFileName);
fIsLogging := FileExists(fFileName);
fIsDetailed := IsDetailedLog(fFileName);
end;
constructor TTotalLog.Create(createlog: Boolean);
var Buffer: array[0..260] of Char;
begin
inherited Create;
SetString(fFileName, Buffer, GetModuleFileName(HInstance, Buffer, SizeOf(Buffer)));
fFileName := GetFileNameWOExt(fFileName) + '.log';
if createlog then CreateFileIfNotExists(fFileName);
fIsLogging := FileExists(fFileName);
fIsDetailed := IsDetailedLog(fFileName);
end;
destructor TTotalLog.Destroy;
begin
inherited;
end;
function TTotalLog.IsBadRPtr(id: LongWord; Str: Pointer; Size: Integer; comment: string): Boolean;
begin
if (not Assigned(Self)) or (not IsLogging) then exit;
Result := IsBadReadPtr(Str, Size);
if Result then begin
logd(id, 'The read pointer is not valid', comment);
raise ELoggedAssertion.Create('The read pointer is not valid (' + comment + ')');
end;
end;
function TTotalLog.IsBadStr(id: LongWord; Str: PChar; Max: Integer; comment: string): Boolean;
begin
if (not Assigned(Self)) or (not IsLogging) then exit;
Result := IsBadStringPtr(Str, Max);
if Result then
logd(id, 'The string pointer is not valid', comment);
end;
function TTotalLog.IsBadWPtr(id: LongWord; Str: Pointer; Size: Integer; comment: string): Boolean;
begin
if (not Assigned(Self)) or (not IsLogging) then exit;
Result := IsBadWritePtr(Str, Size);
if Result then begin
logd(id, 'The write pointer is not valid', comment);
raise ELoggedAssertion.Create('The write pointer is not valid (' + comment + ')');
end;
end;
function TTotalLog.IsDetailedLog(fn: string): Boolean;
var f: TextFile;
s: string;
begin
if not FileExists(fn) then Result := false;
AssignFile(f, fn);
Reset(f);
try
Readln(f, s);
Result := lowercase(s) = 'detailed';
finally
Closefile(f);
end;
end;
procedure TTotalLog.lassert(id: LongWord; exp: Boolean; comment: string; raiseEx: Boolean);
begin
if (not Assigned(Self)) or (not IsLogging) then exit;
if not exp then begin
logd(id, 'Assertion failed', comment);
if raiseEx then
raise ELoggedAssertion.Create('Assertion failed (' + comment + ')');
end;
end;
procedure TTotalLog.log(id: LongWord; const str: string; comment: string);
begin
if IsDetailed then
logd(id, str, comment);
end;
procedure TTotalLog.logd(id: LongWord; const str: string; comment: string);
var addon, st: string;
begin
if (not Assigned(Self)) or (not IsLogging) then exit;
if comment <> '' then
st := Format(' [%s]', [comment])
else
st := '';
if IsDetailed then
addon := IntToHex(id, 8) + ' : '
else
addon := '';
logdirect(FormatDateTime('mm.dd.yy hh":"mm ":" ', Now) + addon + str + st);
end;
procedure TTotalLog.logdirect(str: string);
var f: Textfile;
begin
if (not Assigned(Self)) or (not IsLogging) then exit;
try
AssignFile(f, FileName);
Append(f);
try
Writeln(f, str);
finally
Closefile(f);
end;
except {} end;
end;
procedure TTotalLog.logf(id: LongWord; const form: string; const Args: array of const);
begin
logd(id, Format(form, Args));
end;
procedure TTotalLog.ShowLog;
var ftl: TfTotalLogView;
begin
ftl := TfTotalLogView.Create(Self);
try
ftl.Execute;
finally
ftl.Free;
end;
end;
end.
|
unit cStatistics;
interface
uses OffsetList, contnrs, SysUtils, iNESImage;
type
TStatistic = class(T1ByteProperty)
protected
_MaximumValue : Byte;
_List : String;
function GetValue : Byte;override;
procedure SetValue(pByte : Byte);override;
public
constructor Create(pROM : TiNESImage;pName : String;pOffset : Integer);
property MaximumValue : Byte read _MaximumValue write _MaximumValue;
property List : String read _List write _List;
end;
TStatisticList = class(TObjectList)
private
function Get1BytePropertyItem(Index: Integer) : TStatistic;
procedure Set1BytePropertyItem(Index: Integer; const Value: TStatistic);
public
function Add(AT1ByteProperty : TStatistic) : Integer;
property Items[Index: Integer] : TStatistic read Get1BytePropertyItem write Set1BytePropertyItem;default;
function Last : TStatistic;
function Find(pName : String) : TStatistic;
end;
implementation
function TStatisticList.Get1BytePropertyItem(Index: Integer) : TStatistic;
begin
Result := TStatistic(inherited Items[Index]);
end;
procedure TStatisticList.Set1BytePropertyItem(Index: Integer; const Value: TStatistic);
begin
inherited Items[Index] := Value;
end;
function TStatisticList.Add(AT1ByteProperty : TStatistic) : Integer;
//var
// TempByteProp : T1ByteProperty;
begin
{ TempByteProp := T1ByteProperty.Create(_iNESImage,pName,pOffset);
result := inherited add(TempByteProp);
TempByteProp := nil;}
result := inherited add(AT1ByteProperty);
end;
function TStatisticList.Last : TStatistic;
begin
result := TStatistic(inherited Last);
end;
function TStatisticList.Find(pName : String) : TStatistic;
var
i : Integer;
begin
result := nil;
for i := 0 to self.Count -1 do
begin
if AnsiLowerCase(Items[i].Name) = AnsiLowerCase(pName) then
begin
result := Items[i];
exit;
end;
end;
end;
{ TStatistic }
constructor TStatistic.Create(pROM : TiNESImage;pName : String;pOffset : Integer);
begin
inherited Create(pName,pOffset);
self._MaximumValue := $FF;
end;
function TStatistic.GetValue : Byte;
begin
result := ROM[_Offset];
end;
procedure TStatistic.SetValue(pByte : Byte);
begin
if pByte <= self._MaximumValue then
ROM[_Offset] := pByte
else
ROM[_Offset] := self._MaximumValue;
end;
end.
|
unit Controller.Usuarios;
interface
uses System.SysUtils, FireDAC.Comp.Client, Forms, Windows, Common.ENum, Model.UsuariosJornal;
type
TUsuarioControl = class
private
FUsuarios : TUsuarios;
public
constructor Create;
destructor Destroy; override;
property Usuarios: TUsuarios read FUsuarios write FUsuarios;
function GetID: Integer;
function Localizar(aParam: array of variant): TFDQuery;
function Gravar(): Boolean;
function ValidaLogin(sLogin: String; sSenha: String): Boolean;
function AlteraSenha(AUsuarios: TUsuarios): Boolean;
function ValidaCampos(): Boolean;
function LoginExiste(sLogin: String): Boolean;
function SaveData(memTab: TFDMemTable): Boolean;
end;
implementation
{ TUsuarioControl }
function TUsuarioControl.AlteraSenha(AUsuarios: TUsuarios): Boolean;
begin
Result := False;
if AUsuarios.Senha.IsEmpty then
begin
Application.MessageBox('Informe a nova senha.', 'Atenção', MB_OK + MB_ICONASTERISK);
Exit;
end;
Result := FUsuarios.AlteraSenha(AUsuarios);
end;
constructor TUsuarioControl.Create;
begin
FUsuarios := TUsuarios.Create;
end;
destructor TUsuarioControl.Destroy;
begin
FUsuarios.Free;
inherited;
end;
function TUsuarioControl.GetID: Integer;
begin
Result := FUsuarios.GetID;
end;
function TUsuarioControl.Gravar: Boolean;
begin
Result := False;
if not ValidaCampos() then Exit;
Result := FUsuarios.Gravar;
end;
function TUsuarioControl.Localizar(aParam: array of variant): TFDQuery;
begin
Result := FUsuarios.Localizar(aParam);
end;
function TUsuarioControl.LoginExiste(sLogin: String): Boolean;
begin
Result := FUsuarios.LoginExiste(sLogin);
end;
function TUsuarioControl.SaveData(memTab: TFDMemTable): Boolean;
begin
Result := Fusuarios.SaveData(memTab);
end;
function TUsuarioControl.ValidaCampos: Boolean;
begin
Result := False;
if Fusuarios.Acao = tacExcluir then
begin
Result := True;
Exit;
end;
if FUsuarios.Nome.IsEmpty then
begin
Application.MessageBox('Informe a nome do usuário.', 'Atenção', MB_OK + MB_ICONASTERISK);
Exit;
end;
if FUsuarios.Login.IsEmpty then
begin
Application.MessageBox('Informe o login do usuário.', 'Atenção', MB_OK + MB_ICONASTERISK);
Exit;
end;
if FUsuarios.Senha.IsEmpty then
begin
Application.MessageBox('Informe a nome do usuário.', 'Atenção', MB_OK + MB_ICONASTERISK);
Exit;
end;
if FUsuarios.Acao = Common.ENum.tacIncluir then
begin
if LoginExiste(FUsuarios.Login) then
begin
Application.MessageBox('Login já cadastrado.', 'Atenção', MB_OK + MB_ICONASTERISK);
Exit;
end;
end;
Result := True;
end;
function TUsuarioControl.ValidaLogin(sLogin, sSenha: String): Boolean;
begin
Result := False;
if sLogin.IsEmpty then
begin
Application.MessageBox('Informe o login do usuário.', 'Atenção', MB_OK + MB_ICONASTERISK);
Exit;
end;
if sSenha.IsEmpty then
begin
Application.MessageBox('Informe a nome do usuário.', 'Atenção', MB_OK + MB_ICONASTERISK);
Exit;
end;
Result := FUsuarios.ValidaLogin(sLogin, sSenha);
end;
end.
|
unit m6805;
interface
uses {$IFDEF WINDOWS}windows,{$ENDIF}
dialogs,sysutils,timer_engine,main_engine,cpu_misc;
const
tipo_m6805=0;
tipo_m68705=1;
tipo_hd63705=2;
type
band_m6805=record
h,i,n,z,c:boolean;
end;
reg_m6805=record
pc:word;
sp,sp_mask,sp_low:word;
cc:band_m6805;
a,x:byte;
end;
preg_m6805=^reg_m6805;
cpu_m6805=class(cpu_class)
constructor create(clock:dword;frames_div:word;tipo_cpu:byte);
destructor free;
public
procedure run(maximo:single);
procedure reset;
procedure irq_request(irq,valor:byte);
private
r:preg_m6805;
pedir_irq:array[0..9] of byte;
irq_pending:boolean;
tipo_cpu:byte;
function dame_pila:byte;
procedure pon_pila(valor:byte);
//procedure putword(direccion:word;valor:word);
function getword(direccion:word):word;
procedure pushbyte(valor:byte);
procedure pushword(valor:word);
function pullbyte:byte;
function pullword:word;
end;
var
m6805_0:cpu_m6805;
implementation
const
dir_mode_6805:array[0..$ff] of byte=(
// 0 1 2 3 4 5 6 7 8 9 a b c d e f
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, //00
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, //10
3, 3, 3, 0, 3, 3, 3, 3, 0, 0, 3, 3, 0, 0, 3, 3, //20
0, 0, 0, 0, 0, 0, 7, 0, 7, 7, 7, 0, 7, 7, 0, 4, //30
1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, //40
0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, //50
0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 6, 0, 6, 0, 0, 6, //60
0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 9, 0, 0, 0, 0, 9, //70
1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //80
0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, //90
3, 3, 0, 3, 3, 0, 3, 0, 3, 0, 0, 3, 0, 3, 3, 0, //a0
4, 4, 0, 0, 4, 0, 7, 4, 0, 4, 7, 7, 4, 4, 7, 4, //b0
8, 8, 0, 0, 0, 0, 8, 2, 8, 0, 8, 8, 2, 2, 8, 2, //c0
0, 5, 5, 0, 5, 0, 5, 5, 5, 5, 0, 5, 5, 0, 0, 0, //d0
0, 0, 0, 0, 0, 0, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, //e0
0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 9, 0, 0, 0, 0); //f0
ciclos_6805:array[0..$ff] of byte=(
// 0 1 2 3 4 5 6 7 8 9 A B C D E F */
10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
4, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
6, 0, 0, 6, 6, 0, 6, 6, 6, 6, 6, 6, 0, 6, 6, 0,
4, 0, 0, 4, 4, 0, 4, 4, 4, 4, 4, 0, 4, 4, 0, 4,
4, 0, 0, 4, 4, 0, 4, 4, 4, 4, 4, 0, 4, 4, 0, 4,
7, 0, 0, 7, 7, 0, 7, 7, 7, 7, 7, 0, 7, 7, 0, 7,
6, 0, 0, 6, 6, 0, 6, 6, 6, 6, 6, 0, 6, 6, 0, 6,
9, 6, 0,11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 0, 2,
2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 0, 8, 2, 0,
4, 4, 4, 4, 4, 4, 4, 5, 4, 4, 4, 4, 3, 7, 4, 5,
5, 5, 5, 5, 5, 5, 5, 6, 5, 5, 5, 5, 4, 8, 5, 6,
6, 6, 6, 6, 6, 6, 6, 7, 6, 6, 6, 6, 5, 9, 6, 7,
5, 5, 5, 5, 5, 5, 5, 6, 5, 5, 5, 5, 4, 8, 5, 6,
4, 4, 4, 4, 4, 4, 4, 5, 4, 4, 4, 4, 3, 7, 4, 5);
constructor cpu_m6805.create(clock:dword;frames_div:word;tipo_cpu:byte);
begin
getmem(self.r,sizeof(reg_m6805));
fillchar(self.r^,sizeof(reg_m6805),0);
self.numero_cpu:=cpu_main_init(clock div 4);
self.clock:=clock div 4;
self.tipo_cpu:=tipo_cpu;
self.tframes:=(clock/4/frames_div)/llamadas_maquina.fps_max;
end;
destructor cpu_m6805.free;
begin
freemem(self.r);
end;
procedure cpu_m6805.reset;
var
f:byte;
begin
r.cc.h:=false;
r.cc.i:=true;
r.cc.n:=false;
r.cc.z:=false;
r.cc.c:=false;
self.opcode:=false;
r.pc:=self.getword($fffe);
r.a:=0;
r.x:=0;
self.contador:=0;
r.sp:=$7f;
r.sp_mask:=$7f;
r.sp_low:=$60;
self.change_nmi(CLEAR_LINE);
self.change_reset(CLEAR_LINE);
for f:=0 to 9 do self.pedir_irq[f]:=CLEAR_LINE;
self.irq_pending:=false;
end;
procedure cpu_m6805.irq_request(irq,valor:byte);
begin
self.pedir_irq[irq]:=valor;
if valor<>CLEAR_LINE then self.irq_pending:=true;
end;
function cpu_m6805.dame_pila:byte;
var
temp:byte;
begin
temp:=0;
if r.cc.h then temp:=temp or $10;
if r.cc.i then temp:=temp or $8;
if r.cc.n then temp:=temp or 4;
if r.cc.z then temp:=temp or 2;
if r.cc.c then temp:=temp or 1;
dame_pila:=temp;
end;
procedure cpu_m6805.pon_pila(valor:byte);
begin
r.cc.h:=(valor and $10)<>0;
r.cc.i:=(valor and $8)<>0;
r.cc.n:=(valor and 4)<>0;
r.cc.z:=(valor and 2)<>0;
r.cc.c:=(valor and 1)<>0;
end;
{procedure cpu_m6805.putword(direccion:word;valor:word);
begin
self.putbyte(direccion,valor shr 8);
self.putbyte(direccion+1,valor and $FF);
end;}
function cpu_m6805.getword(direccion:word):word;
var
valor:word;
begin
valor:=self.getbyte(direccion) shl 8;
valor:=valor+(self.getbyte(direccion+1));
getword:=valor;
end;
procedure cpu_m6805.pushbyte(valor:byte);
begin
self.putbyte(r.sp,valor);
r.sp:=r.sp-1;
if r.sp<r.sp_low then r.sp:=r.sp_mask;
end;
procedure cpu_m6805.pushword(valor:word);
begin
self.putbyte(r.sp,valor and $ff);
r.sp:=r.sp-1;
if r.sp<r.sp_low then r.sp:=r.sp_mask;
self.putbyte(r.sp,valor shr 8);
r.sp:=r.sp-1;
if r.sp<r.sp_low then r.sp:=r.sp_mask;
end;
function cpu_m6805.pullbyte:byte;
begin
r.sp:=r.sp+1;
if r.sp>r.sp_mask then r.sp:=r.sp_low;
pullbyte:=self.getbyte(r.sp);
end;
function cpu_m6805.pullword:word;
var
res:word;
begin
r.sp:=r.sp+1;
if r.sp>r.sp_mask then r.sp:=r.sp_low;
res:=self.getbyte(r.sp) shl 8;
r.sp:=r.sp+1;
if r.sp>r.sp_mask then r.sp:=r.sp_low;
res:=res+byte(self.getbyte(r.sp));
pullword:=res;
end;
procedure cpu_m6805.run(maximo:single);
var
instruccion,numero,tempb:byte;
posicion,tempw:word;
begin
self.contador:=0;
while self.contador<maximo do begin
if self.pedir_reset<>CLEAR_LINE then begin
tempb:=self.pedir_reset;
self.reset;
if tempb=ASSERT_LINE then begin
self.pedir_reset:=ASSERT_LINE;
self.contador:=trunc(maximo);
exit;
end;
end;
self.estados_demas:=0;
if self.tipo_cpu=tipo_m68705 then begin
if (self.irq_pending) then begin
if not(r.cc.i) then begin
self.pushword(r.pc);
self.pushbyte(r.x);
self.pushbyte(r.a);
self.pushbyte(self.dame_pila);
r.cc.i:=true;
if self.irq_pending then begin //Req IRQ
self.irq_pending:=false;
r.pc:=self.getword($fffa);
end;{ else begin
if r.pedir_irq[1] then begin //Timer IRQ
r.pedir_irq[1]:=false;
r.pc:=getword($fff8,ll);
end;
end; }
self.estados_demas:=11;
end;
end;
end else MessageDlg('IRQ No implementadas '+inttostr(self.numero_cpu), mtInformation,[mbOk], 0);
self.opcode:=true;
instruccion:=self.getbyte(r.pc);
r.pc:=r.pc+1;
self.opcode:=false;
//tipo de paginacion
case dir_mode_6805[instruccion] of
0:MessageDlg('Num CPU '+inttostr(self.numero_cpu)+' instruccion: '+inttohex(instruccion,2)+' desconocida. PC='+inttohex(r.pc-1,10), mtInformation,[mbOk], 0);
1:; //inerent
2:begin //extended
posicion:=self.getword(r.pc);
r.pc:=r.pc+2;
numero:=self.getbyte(posicion);
end;
3:begin //immbyte
numero:=self.getbyte(r.pc);
r.pc:=r.pc+1;
end;
4:begin //direct
posicion:=self.getbyte(r.pc);
r.pc:=r.pc+1;
numero:=self.getbyte(posicion);
end;
5:begin //idx 2 byte
posicion:=self.getword(r.pc);
r.pc:=r.pc+2;
posicion:=posicion+r.x;
numero:=self.getbyte(posicion);
end;
6:begin //IDX1BYTE
posicion:=self.getbyte(r.pc);
r.pc:=r.pc+1;
posicion:=posicion+r.x;
numero:=self.getbyte(posicion);
end;
7:begin //dirbyte
posicion:=self.getbyte(r.pc);
r.pc:=r.pc+1;
numero:=self.getbyte(posicion);
end;
8:begin //extbyte
posicion:=self.getword(r.pc);
r.pc:=r.pc+2;
numero:=self.getbyte(posicion);
end;
9:begin
posicion:=r.x; //idxbyte
numero:=self.getbyte(posicion);
end;
end;
case instruccion of
$00,$02,$04,$06,$08,$0a,$0c,$0e:begin //brset
tempb:=self.getbyte(r.pc);
r.pc:=r.pc+1;
r.cc.c:=false;
if ((numero and (1 shl ((instruccion shr 1) and $7)))<>0) then begin
r.cc.c:=true;
r.pc:=r.pc+shortint(tempb);
end;
end;
$01,$03,$05,$07,$09,$0b,$0d,$0f:begin //brclr
tempb:=self.getbyte(r.pc);
r.pc:=r.pc+1;
r.cc.c:=true;
if ((numero and (1 shl ((instruccion shr 1) and $7)))=0) then begin
r.cc.c:=false;
r.pc:=r.pc+shortint(tempb);
end;
end;
$10,$12,$14,$16,$18,$1a,$1c,$1e:begin //bset
tempb:=numero or (1 shl ((instruccion shr 1) and $7));
self.putbyte(posicion,tempb);
end;
$11,$13,$15,$17,$19,$1b,$1d,$1f:begin //bclr
tempb:=numero and not(1 shl ((instruccion shr 1) and $7));
self.putbyte(posicion,tempb);
end;
$20:r.pc:=r.pc+shortint(numero); //bra
$21:; //brn
$22:if (not(r.cc.z) and not(r.cc.c)) then r.pc:=r.pc+shortint(numero); //bhi
$24:if not(r.cc.c) then r.pc:=r.pc+shortint(numero); //bcc
$25:if r.cc.c then r.pc:=r.pc+shortint(numero); //bcs
$26:if not(r.cc.z) then r.pc:=r.pc+shortint(numero); //bne
$27:if r.cc.z then r.pc:=r.pc+shortint(numero); //beq
$2a:if not(r.cc.n) then r.pc:=r.pc+shortint(numero); //bpl
$2b:if r.cc.n then r.pc:=r.pc+shortint(numero); //bmi
$2e:if self.tipo_cpu=tipo_hd63705 then begin //bil
if self.pedir_nmi<>CLEAR_LINE then r.pc:=r.pc+shortint(numero);
end else begin
if self.pedir_irq[0]<>CLEAR_LINE then r.pc:=r.pc+shortint(numero);
end;
$2f:if self.tipo_cpu=tipo_hd63705 then begin //bhi
if self.pedir_nmi=CLEAR_LINE then r.pc:=r.pc+shortint(numero);
end else begin
if self.pedir_irq[0]=CLEAR_LINE then r.pc:=r.pc+shortint(numero);
end;
$36,$66,$76:begin //ror
if r.cc.c then tempb:=$80
else tempb:=0;
r.cc.c:=(numero and $01)<>0;
tempb:=tempb or (numero shr 1);
r.cc.z:=(tempb=0);
r.cc.n:=(tempb and $80)<>0;
self.putbyte(posicion,tempb);
end;
$38:begin //asl
tempw:=numero shl 1;
r.cc.z:=(tempw=0);
r.cc.n:=(tempw and $80)<>0;
r.cc.c:=(tempw and $100)<>0;
self.putbyte(posicion,tempw and $ff);
end;
$39:begin //rol
if r.cc.c then tempw:=$01 or (numero shl 1)
else tempw:=numero shl 1;
r.cc.z:=(tempw=0);
r.cc.n:=(tempw and $80)<>0;
r.cc.c:=(tempw and $100)<>0;
self.putbyte(posicion,tempw and $ff);
end;
$3a,$6a,$7a:begin //dec
numero:=numero-1;
r.cc.z:=(numero=0);
r.cc.n:=(numero and $80)<>0;
self.putbyte(posicion,numero);
end;
$3c,$6c:begin //inc
numero:=numero+1;
r.cc.z:=(numero=0);
r.cc.n:=(numero and $80)<>0;
self.putbyte(posicion,numero);
end;
$3d:begin //tst
r.cc.z:=(numero=0);
r.cc.n:=(numero and $80)<>0;
end;
$3f,$6f,$7f:begin //clr
r.cc.n:=false;
r.cc.c:=false;
r.cc.z:=true;
self.putbyte(posicion,0);
end;
$40:begin //nega
tempw:=-r.a;
r.cc.z:=(tempw=0);
r.cc.n:=(tempw and $80)<>0;
r.cc.c:=(tempw and $100)<>0;
r.a:=tempw;
end;
$44:begin //lsra
r.cc.n:=false;
r.cc.c:=(r.a and $01)<>0;
r.a:=r.a shr 1;
r.cc.z:=(r.a=0);
end;
$47:begin //asra
r.cc.c:=(r.a and $01)<>0;
r.a:=(r.a and $80) or (r.a shr 1);
r.cc.z:=(r.a=0);
r.cc.n:=(r.a and $80)<>0;
end;
$48:begin //lsla
tempw:=r.a shl 1;
r.cc.z:=(tempw=0);
r.cc.n:=(tempw and $80)<>0;
r.cc.c:=(tempw and $100)<>0;
r.a:=tempw;
end;
$49:begin //rola
if r.cc.c then tempw:=$01 or (r.a shl 1)
else tempw:=r.a shl 1;
r.cc.z:=(tempw=0);
r.cc.n:=(tempw and $80)<>0;
r.cc.c:=(tempw and $100)<>0;
r.a:=tempw;
end;
$4a:begin //deca
r.a:=r.a-1;
r.cc.z:=(r.a=0);
r.cc.n:=(r.a and $80)<>0;
end;
$4c:begin //inca
r.a:=r.a+1;
r.cc.z:=(r.a=0);
r.cc.n:=(r.a and $80)<>0;
end;
$4d:begin //tsta
r.cc.z:=(r.a=0);
r.cc.n:=(r.a and $80)<>0;
end;
$4f:begin //clra
r.cc.n:=false;
r.cc.z:=true;
r.a:=0;
end;
$56:begin //rorx
tempb:=byte(r.cc.c)*$80 or (r.x shr 1);
r.cc.c:=(r.x and 1)<>0;
r.cc.z:=(tempb=0);
r.cc.n:=(tempb and $80)<>0;
r.x:=tempb;
end;
$54:begin //lsrx
r.cc.n:=false;
r.cc.c:=(r.x and $01)<>0;
r.x:=r.x shr 1;
r.cc.z:=(r.x=0);
end;
$58:begin //aslx
tempw:=r.x shl 1;
r.cc.n:=(tempw and $80)<>0;
r.cc.z:=(tempw=0);
r.cc.c:=(tempw and $100)<>0;
r.x:=tempw;
end;
$59:begin //rolx
if r.cc.c then tempw:=$01 or (r.x shl 1)
else tempw:=r.x shl 1;
r.cc.n:=(tempw and $80)<>0;
r.cc.z:=(tempw=0);
r.cc.c:=(tempw and $100)<>0;
r.x:=tempw;
end;
$5a:begin //decx
r.x:=r.x-1;
r.cc.z:=(r.x=0);
r.cc.n:=(r.x and $80)<>0;
end;
$5c:begin //incx
r.x:=r.x+1;
r.cc.z:=(r.x=0);
r.cc.n:=(r.x and $80)<>0;
end;
$5d:begin //tstx
r.cc.z:=(r.x=0);
r.cc.n:=(r.x and $80)<>0;
end;
$5f:begin //clrx
r.x:=0;
r.cc.z:=true;
r.cc.n:=false;
r.cc.c:=false;
end;
$80:begin //rti
self.pon_pila(self.pullbyte);
r.a:=self.pullbyte;
r.x:=self.pullbyte;
r.pc:=self.pullword;
end;
$81:r.pc:=self.pullword; //rts
$97:r.x:=r.a; //tax
$98:r.cc.c:=false; //clc
$99:r.cc.c:=true; //sec
$9a:r.cc.i:=false; //cli
$9b:r.cc.i:=true; //sei
$9c:r.sp:=r.sp_mask;//rsp
$9d:; //nop
$9f:r.a:=r.x; //txa
$a0,$b0,$c0:begin //suba
tempw:=r.a-numero;
r.cc.z:=(tempw=0);
r.cc.c:=(tempw and $100)<>0;
r.cc.n:=(tempw and $80)<>0;
r.a:=tempw;
end;
$a1,$b1,$c1,$d1:begin //cmpa
tempw:=r.a-numero;
r.cc.z:=(tempw=0);
r.cc.c:=(tempw and $100)<>0;
r.cc.n:=(tempw and $80)<>0;
end;
$d2:begin //sbca
if r.cc.c then tempw:=r.a-numero-1
else tempw:=r.a-numero;
r.cc.z:=(tempw=0);
r.cc.c:=(tempw and $100)<>0;
r.cc.n:=(tempw and $80)<>0;
r.a:=tempw;
end;
$a3:begin //cmpx
tempw:=r.x-numero;
r.cc.z:=(tempw=0);
r.cc.c:=(tempw and $100)<>0;
r.cc.n:=(tempw and $80)<>0;
end;
$a4,$b4,$d4:begin //anda
r.a:=r.a and numero;
r.cc.z:=(r.a=0);
r.cc.n:=(r.a and $80)<>0;
end;
$a6,$b6,$c6,$e6,$d6,$f6:begin //lda
r.a:=numero;
r.cc.z:=(numero=0);
r.cc.n:=(numero and $80)<>0;
end;
$b7,$c7,$d7,$e7,$f7:begin //sta
r.cc.z:=(r.a=0);
r.cc.n:=(r.a and $80)<>0;
self.putbyte(posicion,r.a);
end;
$a8,$c8,$d8:begin //eora
r.a:=r.a xor numero;
r.cc.z:=(r.a=0);
r.cc.n:=(r.a and $80)<>0;
end;
$b9,$d9:begin //adca
if r.cc.c then tempw:=r.a+numero+$01
else tempw:=r.a+numero;
r.cc.z:=(tempw=0);
r.cc.n:=(tempw and $80)<>0;
r.cc.c:=(tempw and $100)<>0;
r.cc.h:=((r.a xor numero xor tempw) and $10)<>0;
r.a:=tempw;
end;
$ca,$ba:begin //ora
r.a:=r.a or numero;
r.cc.z:=(r.a=0);
r.cc.n:=(r.a and $80)<>0;
end;
$ab,$bb,$cb,$db,$fb:begin //adda
tempw:=r.a+numero;
r.cc.z:=(tempw=0);
r.cc.n:=(tempw and $80)<>0;
r.cc.c:=(tempw and $100)<>0;
r.cc.h:=((r.a xor numero xor tempw) and $10)<>0;
r.a:=tempw;
end;
$bc,$cc,$dc:r.pc:=posicion; //jmp
$ad:begin //bsr
self.pushword(r.pc);
r.pc:=r.pc+shortint(numero);
end;
$bd,$cd:begin //jsr
self.pushword(r.pc);
r.pc:=posicion;
end;
$ae,$be,$ce:begin //ldx
r.x:=numero;
r.cc.z:=(numero=0);
r.cc.n:=(numero and $80)<>0;
end;
$bf,$cf:begin //stx
r.cc.z:=(r.x=0);
r.cc.n:=(r.x and $80)<>0;
self.putbyte(posicion,r.x);
end;
end; //del case
self.contador:=self.contador+ciclos_6805[instruccion]+self.estados_demas;
timers.update(ciclos_6805[instruccion]+self.estados_demas,self.numero_cpu);
end; //del while
end;
end.
|
{$include lem_directives.inc}
unit LemTerrain;
interface
uses
Classes,
UTools,
LemPiece;
const
// Terrain Drawing Flags
tdf_Erase = 1; // bit 0 use terrain bitmap as eraser
tdf_Invert = 2; // bit 1 invert terrain bitmap
tdf_NoOverwrite = 4; // bit 2 do not overwrite existing terrain pixels
type
TTerrainClass = class of TTerrain;
TTerrain = class(TIdentifiedPiece)
private
protected
fDrawingFlags : Byte;
public
procedure Assign(Source: TPersistent); override;
published
property DrawingFlags: Byte read fDrawingFlags write fDrawingFlags;
end;
type
TTerrains = class(TPieces)
private
function GetItem(Index: Integer): TTerrain;
procedure SetItem(Index: Integer; const Value: TTerrain);
protected
public
constructor Create(aItemClass: TTerrainClass);
function Add: TTerrain;
function Insert(Index: Integer): TTerrain;
property Items[Index: Integer]: TTerrain read GetItem write SetItem; default;
published
end;
implementation
{ TTerrain }
procedure TTerrain.Assign(Source: TPersistent);
var
T: TTerrain absolute Source;
begin
if Source is TTerrain then
begin
inherited Assign(Source);
DrawingFlags := T.DrawingFlags;
end
else inherited Assign(Source);
end;
{ TTerrains }
function TTerrains.Add: TTerrain;
begin
Result := TTerrain(inherited Add);
end;
constructor TTerrains.Create(aItemClass: TTerrainClass);
begin
inherited Create(aItemClass);
end;
function TTerrains.GetItem(Index: Integer): TTerrain;
begin
Result := TTerrain(inherited GetItem(Index))
end;
function TTerrains.Insert(Index: Integer): TTerrain;
begin
Result := TTerrain(inherited Insert(Index))
end;
procedure TTerrains.SetItem(Index: Integer; const Value: TTerrain);
begin
inherited SetItem(Index, Value);
end;
end.
|
//---------------------------------------------------------------------------
// This software is Copyright (c) 2015 Embarcadero Technologies, Inc.
// You may only use this software if you are an authorized licensee
// of an Embarcadero developer tools product.
// This software is considered a Redistributable as defined under
// the software license agreement that comes with the Embarcadero Products
// and is subject to that software license agreement.
//---------------------------------------------------------------------------
unit MainTestBed;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls, FMX.Objects, FMX.ListBox, FMX.Layouts,
FMX.Controls.Presentation, Box2D.Collision, Box2D.Common, Box2D.Dynamics, Box2D.Rope, Box2DTypes, Test;
type
TForm6 = class(TForm)
MainPanel: TPanel;
RightPanel: TPanel;
RightLayout: TLayout;
TestLabel: TLabel;
TestList: TComboBox;
Line1: TLine;
EnableLayout: TLayout;
Sleep: TCheckBox;
WarmStarting: TCheckBox;
TimeOfImpact: TCheckBox;
SubStepping: TCheckBox;
DrawLayout: TLayout;
ShapesChk: TCheckBox;
AABBsChk: TCheckBox;
ContactPointsChk: TCheckBox;
ContactNormalsChk: TCheckBox;
ContactImpulsesChk: TCheckBox;
FrictionImpulsesChk: TCheckBox;
CenterOfMassesChk: TCheckBox;
ProfileChk: TCheckBox;
StatisticsChk: TCheckBox;
JointsChk: TCheckBox;
ButtonsLayout: TLayout;
QuiBtn: TButton;
RestartBtn: TButton;
SingleStepBtn: TButton;
PauseBtn: TButton;
PaintBox: TPaintBox;
RightSplitter: TSplitter;
Timer1: TTimer;
procedure FormShow(Sender: TObject);
procedure FormResize(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure PaintBoxPaint(Sender: TObject; Canvas: TCanvas);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure TestListChange(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState);
procedure FormKeyUp(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState);
procedure PaintBoxMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Single);
procedure PaintBoxMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Single);
procedure PaintBoxMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Single);
procedure PauseBtnClick(Sender: TObject);
procedure SingleStepBtnClick(Sender: TObject);
procedure RestartBtnClick(Sender: TObject);
procedure QuiBtnClick(Sender: TObject);
private
{ Private declarations }
testIndex: Int32;
testSelection: Int32;
testCount: Int32;
entry: PTestEntry;
test: PTest;
settings: PSettings;
rightMouseDown: Boolean;
lastp: b2Vec2;
procedure DrawLayoutChanged(Sender: TObject);
public
{ Public declarations }
procedure LoadTests;
procedure TestChanged;
procedure ResetView;
end;
var
Form6: TForm6;
implementation
{$R *.fmx}
procedure TForm6.DrawLayoutChanged(Sender: TObject);
begin
settings.drawShapes := ShapesChk.IsChecked;
settings.drawJoints := JointsChk.IsChecked;
settings.drawAABBs := AABBsChk.IsChecked;
settings.drawContactPoints := ContactPointsChk.IsChecked;
settings.drawContactNormals := ContactNormalsChk.IsChecked;
settings.drawContactImpulse := ContactImpulsesChk.IsChecked;
settings.drawFrictionImpulse := FrictionImpulsesChk.IsChecked;
settings.drawCOMs := CenterOfMassesChk.IsChecked;
settings.drawStats := StatisticsChk.IsChecked;
settings.drawProfile := ProfileChk.IsChecked;
end;
procedure TForm6.FormCreate(Sender: TObject);
begin
LoadTests;
end;
procedure TForm6.FormDestroy(Sender: TObject);
begin
Timer1.Enabled := False;
// Test* t = test;
// test = 0;
// delete t;
end;
procedure TForm6.FormKeyDown(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState);
begin
// bool modCtrl = Shift.Contains(ssCtrl);
// switch(Key)
// {
// case vkEscape:
// // Quit
// Close();
// break;
//
// case vkLeft:
// // Pan left
// if (modCtrl && test)
// {
// b2Vec2 newOrigin(2.0f, 0.0f);
// test->ShiftOrigin(newOrigin);
// }
// else
// {
// g_camera.m_center.x -= 0.5f;
// g_debugDraw.OffsetX = g_debugDraw.OffsetX-1;
// }
// break;
//
// case vkRight:
// // Pan right
// if (modCtrl && test)
// {
// b2Vec2 newOrigin(-2.0f, 0.0f);
// test->ShiftOrigin(newOrigin);
// }
// else
// {
// g_camera.m_center.x += 0.5f;
// g_debugDraw.OffsetX = g_debugDraw.OffsetX+1;
// }
// break;
//
// case vkDown:
// // Pan down
// if (modCtrl && test)
// {
// b2Vec2 newOrigin(0.0f, 2.0f);
// test->ShiftOrigin(newOrigin);
// }
// else
// {
// g_camera.m_center.y -= 0.5f;
// g_debugDraw.OffsetY = g_debugDraw.OffsetY-1;
// }
// break;
//
// case vkUp:
// // Pan up
// if (modCtrl && test)
// {
// b2Vec2 newOrigin(0.0f, -2.0f);
// test->ShiftOrigin(newOrigin);
// }
// else
// {
// g_camera.m_center.y += 0.5f;
// g_debugDraw.OffsetY = g_debugDraw.OffsetY+1;
// }
// break;
//
// case vkHome:
// // Reset view
// g_camera.m_zoom = 1.0f;
// g_camera.m_center.Set(0.0f, 20.0f);
// break;
//
// case vkSpace:
// // Launch a bomb.
// if (test)
// {
// test->LaunchBomb();
// }
// break;
//
// default:
// switch (KeyChar)
// {
// case 'P':
// case 'p':
// // Pause
// settings.pause = !settings.pause;
// break;
//
// case ' ':
// // Launch a bomb.
// if (test)
// {
// test->LaunchBomb();
// }
// break;
//
// case 'R':
// case 'r':
// // Reset test
// delete test;
// test = entry->createFcn();
// break;
//
// default:
// if (test)
// {
// test->Keyboard(static_cast<int>(ToUpper(KeyChar)));
// }
// }
// }
end;
procedure TForm6.FormKeyUp(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState);
begin
// if (test)
// {
// test->KeyboardUp(static_cast<int>(ToUpper(KeyChar)));
// }
end;
procedure TForm6.FormResize(Sender: TObject);
begin
// ResetView();
end;
procedure TForm6.FormShow(Sender: TObject);
begin
// ResetView();
// DrawLayoutChanged(0);
// TestChanged();
end;
procedure TForm6.LoadTests;
begin
// testCount = 0;
// while (g_testEntries[testCount].createFcn != NULL)
// {
// TestEntry& entry = g_testEntries[testCount];
// TestList->Items->Add(entry.name);
// ++testCount;
// }
//
// TestList->ItemIndex = 0;
// testSelection = 0;
// testIndex = -1;
// test = 0;
end;
procedure TForm6.PaintBoxMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Single);
begin
// if (Button == TMouseButton::mbLeft)
// {
// if (test)
// {
// b2Vec2 pt = g_debugDraw.ScreenToWorld(X, Y);
// if (Shift.Contains(ssShift))
// test->ShiftMouseDown(pt);
// else
// test->MouseDown(pt);
// }
// }
end;
procedure TForm6.PaintBoxMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Single);
begin
// if (test)
// {
// b2Vec2 pt = g_debugDraw.ScreenToWorld(X, Y);
// test->MouseMove(pt);
// }
end;
procedure TForm6.PaintBoxMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Single);
begin
// if (test)
// {
// b2Vec2 pt = g_debugDraw.ScreenToWorld(X, Y);
// test->MouseUp(pt);
// }
end;
procedure TForm6.PaintBoxPaint(Sender: TObject; Canvas: TCanvas);
begin
// Canvas->BeginScene();
// __try {
// Canvas->Fill->Color = TAlphaColorRec::Black;
// TRectF rect = PaintBox->BoundsRect;
// Canvas->FillRect(rect, 0, 0, TCorners(), DEFAULT_OPACITY);
// if (test)
// {
// g_debugDraw.Canvas = Canvas;
// g_debugDraw.Canvas->Fill->Color = TAlphaColorRec::Yellow;
// test->DrawTitle(entry->name);
// g_debugDraw.Canvas->Fill->Color = TAlphaColorRec::Aqua;
// test->Step(&settings);
// }
// }
// __finally {
// Canvas->EndScene();
// }
end;
procedure TForm6.PauseBtnClick(Sender: TObject);
begin
// settings.pause = !settings.pause;
end;
procedure TForm6.QuiBtnClick(Sender: TObject);
begin
Close;
end;
procedure TForm6.ResetView;
begin
// g_debugDraw.OffsetX = PaintBox->Width/2;
// g_debugDraw.OffsetY = PaintBox->Height/2;
// g_debugDraw.ScaleX = 10;
// g_debugDraw.ScaleY = 10;
// g_debugDraw.CanvasHeight = PaintBox->Height;
// g_camera.m_width = PaintBox->Width;
// g_camera.m_height = PaintBox->Height;
// g_camera.m_center.Set(g_debugDraw.OffsetX, g_debugDraw.OffsetY);
end;
procedure TForm6.RestartBtnClick(Sender: TObject);
begin
// delete test;
// test = entry->createFcn();
end;
procedure TForm6.SingleStepBtnClick(Sender: TObject);
begin
// settings.singleStep = !settings.singleStep;
end;
procedure TForm6.TestChanged;
begin
// if (testSelection != testIndex)
// {
// testIndex = testSelection;
// delete test;
// entry = g_testEntries + testIndex;
// test = entry->createFcn();
// }
end;
procedure TForm6.TestListChange(Sender: TObject);
begin
// if (TestList->ItemIndex != testSelection)
// {
// testSelection = TestList->ItemIndex;
// TestChanged();
// }
end;
procedure TForm6.Timer1Timer(Sender: TObject);
begin
// if (test)
// {
// Invalidate();
// }
end;
end.
|
unit flImageList;
interface
uses
SysUtils, Classes, ImgList, Controls;
type
TflImageList = class(TImageList)
private
FWidths: TStrings;
procedure SetWidths(const Value: TStrings);
{ Private declarations }
protected
{ Protected declarations }
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property Widths: TStrings read FWidths write SetWidths;
end;
implementation
{ TflImageList }
constructor TflImageList.Create(AOwner: TComponent);
begin
inherited;
FWidths := TStringList.Create;
end;
destructor TflImageList.Destroy;
begin
FWidths.Free;
inherited;
end;
procedure TflImageList.SetWidths(const Value: TStrings);
begin
FWidths.Assign(Value);
end;
end.
|
unit CsReply;
{ $Id: CsReply.pas,v 1.17 2012/02/24 09:15:25 narry Exp $ }
// $Log: CsReply.pas,v $
// Revision 1.17 2012/02/24 09:15:25 narry
// Запись последнего пинга
// вывод в лог информации
//
// Revision 1.16 2011/12/08 12:32:12 narry
// Отображается не вся очередь заданий (304874341)
//
// Revision 1.15 2011/04/22 11:48:38 narry
// Большая кнопка (262636461)
//
// Revision 1.14 2010/05/17 08:34:02 narry
// - не выводим в лог записи KeepAlive
//
// Revision 1.13 2010/02/26 09:45:25 narry
// - защита от повторного входа
//
// Revision 1.12 2009/07/22 08:20:23 narry
// - новая процедура KeepAlive
// - cleanup
//
// Revision 1.11 2008/10/01 07:45:40 narry
// - добавлен путь к образам документов
//
// Revision 1.10 2008/07/14 07:47:53 narry
// - получение путей к базе с сервера (первый шаг, немного в сторону)
//
// Revision 1.9 2008/03/21 17:32:22 narry
// - задел для превращения Парня в сервис
//
// Revision 1.8 2006/10/12 11:30:40 narry
// - вывод в лог дополнительной информации
//
// Revision 1.7 2006/09/21 11:47:59 narry
// - логгирование сетевых сообщений на стороне сервера
//
// Revision 1.6 2006/09/01 13:55:01 narry
// - при подключении клиента к серверу проверяются версии клиента и сервера
//
// Revision 1.5 2006/08/24 08:48:46 narry
// - исправление: отключение получения номера версии
//
// Revision 1.4 2006/08/03 13:22:01 narry
// - увеличение версии протокола и реакция на ее не совпадение
//
// Revision 1.3 2006/03/16 15:50:16 narry
// - еще один шажок в сторону клиент-сервера
//
// Revision 1.2 2006/03/10 09:29:12 voba
// - enh. убрал CsFree etc.
//
// Revision 1.1 2006/02/08 17:24:29 step
// выполнение запросов перенесено из классов-потомков в процедуры объектов
//
{$I CsDefine.inc}
interface
uses
Contnrs,
IdContext, IdIOHandler,
CsObject, CsCommon, CsConst, CsServer, CsReplyProcedures, CsQueryTypes;
type
TCsReply = class(TCsObject)
private
f_ClientId: TCsClientId;
f_Context: TIdContext;
f_ReplyProcedures: TCsReplyProcedures;
f_Server: TCsServer;
function IOHandler: TIdIOHandler;
procedure OnClientIpQuery;
procedure OnClientLogin;
procedure OnClientLoginEx;
procedure OnClientLogout;
procedure OnGetProtocolVersion;
procedure OnKeepAlive;
function ProcessInternarQuery(aQueryId: TCsQueryId): Boolean;
protected
procedure Cleanup; override;
public
constructor Create(aServer: TCsServer;
aContext: TIdContext;
aReplyProcedures: TCsReplyProcedures); reintroduce;
procedure Run(aLogMessages: Boolean);
property ClientId: TCsClientId read f_ClientId;
property Context: TIdContext read f_Context;
property Server: TCsServer read f_Server;
end;
implementation
uses
Classes, SysUtils,
l3Base,
IdGlobal,
CsErrors, CsDataPipe, CsEventsProcessor, csNotification, csNotifier,
CsActiveClients, TypInfo;
constructor TCsReply.Create(aServer: TCsServer;
aContext: TIdContext;
aReplyProcedures: TCsReplyProcedures);
begin
inherited Create;
Assert(aServer <> nil);
Assert(aContext <> nil);
f_Server := aServer;
f_Context := aContext;
f_Context.Connection.IOHandler.MaxLineLength := c_MaxDataStringLength;
f_Context.Connection.IOHandler.MaxLineAction := maException;
f_ReplyProcedures := aReplyProcedures;
f_ClientId := c_WrongClientId; // пока не известно
end;
{ TCsReply }
procedure TCsReply.Cleanup;
begin
f_Server := nil;
f_ReplyProcedures := nil;
inherited;
end;
function TCsReply.IOHandler: TIdIOHandler;
begin
Result := f_Context.Connection.IOHandler;
end;
procedure TCsReply.OnClientIpQuery;
var
l_ClientIp: TCsIp;
begin
l_ClientIp := f_Context.Binding.PeerIP;
IOHandler.WriteLn(l_ClientIp);
end;
procedure TCsReply.OnClientLogin;
var
l_LoginName: string;
l_Password: string;
l_ListenIp: TCsIp;
l_ListenPort: TCsPort;
l_ClientId: TCsClientId;
l_UID: Int64;
begin
// чтение
l_LoginName := IOHandler.ReadLn;
l_Password := IOHandler.ReadLn;
l_ListenIp := IOHandler.ReadLn;
l_ListenPort := IOHandler.ReadInteger;
l_UID := IOHandler.ReadInt64;
// вычисление
l_ClientId := f_Server.ActiveClients.Login(l_LoginName,
l_Password,
l_ListenIp,
l_ListenPort,
l_UID);
// отправка
IOHandler.Write(l_ClientId);
IOHandler.Write(l_UID);
// нотификация
if (l_ClientID <> c_WrongClientID) and (l_ClientID <> c_DuplicateClient) then
begin
f_Server.EventsProcessor.ProcessEvent(c_ClientLogedInEvent, l_ClientId);
f_Server.Notifier.SendNotify(c_AllClients, ntUserLogin, l_ClientID, '');
end;
end;
procedure TCsReply.OnClientLoginEx;
var
l_LoginName: string;
l_Password: string;
l_ListenIp: TCsIp;
l_ListenPort: TCsPort;
l_ClientId: TCsClientId;
l_UID: Int64;
l_DVer, l_AVer: Integer;
l_Family, l_Table, l_Homes, l_Lock, l_Images: String;
begin
// чтение
l_LoginName := IOHandler.ReadLn;
l_Password := IOHandler.ReadLn;
l_ListenIp := IOHandler.ReadLn;
l_ListenPort := IOHandler.ReadInteger;
l_UID := IOHandler.ReadInt64;
// вычисление
l_ClientId := f_Server.ActiveClients.Login(l_LoginName,
l_Password,
l_ListenIp,
l_ListenPort,
l_UID);
if Assigned(f_Server.OnLoginExData) then
f_Server.OnLoginExData(l_DVer, l_AVer, l_Family, l_Table, l_Homes, l_Lock, l_Images);
// отправка
IOHandler.Write(l_ClientId);
IOHandler.Write(l_UID);
IOHandler.Write(l_DVer);
IOHandler.Write(l_AVer);
IOHandler.WriteLn(l_Family);
IOHandler.WriteLn(l_Table);
IOHandler.WriteLn(l_Homes);
IOHandler.WriteLn(l_Lock);
IOHandler.WriteLn(l_Images);
// нотификация
if (l_ClientID <> c_WrongClientID) and (l_ClientID <> c_DuplicateClient) then
begin
f_Server.EventsProcessor.ProcessEvent(c_ClientLogedInEvent, l_ClientId);
f_Server.Notifier.SendNotify(c_AllClients, ntUserLogin, l_ClientID, '');
end;
end;
procedure TCsReply.OnClientLogout;
begin
f_Server.ActiveClients.Logout(ClientId);
f_Server.EventsProcessor.ProcessEvent(c_ClientLogedOutEvent, ClientId);
f_Server.Notifier.SendNotify(c_AllClients, ntUserLogout, ClientID, '');
end;
procedure TCsReply.OnGetProtocolVersion;
begin
IOHandler.Write(Integer(c_CsVersion));
end;
procedure TCsReply.OnKeepAlive;
var
l_Port: Integer;
l_IP: String;
begin
l_IP:= IOHandler.Readln;
l_Port:= IOHandler.readInteger;
if not f_Server.ActiveClients.IsLogged(ClientID) then
f_Server.RequestLogin(l_IP, l_Port)
else
f_Server.ActiveClients.ClientInfoOf(ClientID).LastPing:= Now;
end;
function TCsReply.ProcessInternarQuery(aQueryId: TCsQueryId): Boolean;
begin
Result := True;
case aQueryId of
qtClientIp: OnClientIpQuery;
qtLogin: OnClientLogin;
qtLoginEx: OnClientLoginEx;
qtLogout: OnClientLogout;
qtKeepAlive: OnKeepAlive;
qtGetProtocolVersion: OnGetProtocolVersion;
else
Result := False;
end;
end;
procedure TCsReply.Run(aLogMessages: Boolean);
var
l_CsVersion: Integer;
l_QueryId: TCsQueryId;
l_ReplyProc: TCsReplyProc;
l_Pipe: TCsDataPipe;
I: Integer;
begin
try
IOHandler.WriteBufferOpen;
try
l_Pipe := TCsDataPipe.Create(IOHandler);
try
l_CsVersion := l_Pipe.ReadInteger;
f_ClientId := l_Pipe.ReadInteger;
l_QueryId := TcsQueryId(l_Pipe.ReadInteger);
if aLogMessages and (l_QueryID <> qtKeepAlive) then
l3System.Msg2Log('Обработка %s от %d', [GetEnumName(TypeInfo(TcsQueryID), ord(l_QueryID)), f_ClientID]);
if l_QueryID <> qtGetProtocolVersion then
ECsWrongVersionError.IfNot(l_CsVersion = c_CsVersion);
if not ProcessInternarQuery(l_QueryId) then
begin
l_ReplyProc := f_ReplyProcedures.ProcBy(l_QueryId);
if Assigned(l_ReplyProc) then
try
l_ReplyProc(l_Pipe)
except
on E: Exception do
l3System.Exception2Log(E);
end
else
if aLogMessages and (l_QueryID <> qtKeepAlive) then
l3System.Msg2Log('Не зарегистрирован обработчик для %s', [GetEnumName(TypeInfo(TcsQueryID), ord(l_QueryID))]);
end; // not ProcessInternarQuery(l_QueryId)
if aLogMessages and (l_QueryID <> qtKeepAlive) then
l3System.Msg2Log('%s от %d обработан', [GetEnumName(TypeInfo(TcsQueryID), ord(l_QueryID)), f_ClientID]);
finally
l3Free(l_Pipe);
end;
finally
IOHandler.WriteBufferClose;
end;
finally
f_Context.Connection.Disconnect(False);
f_Context.Connection.IOHandler.InputBuffer.Clear;
end;
end;
end.
|
unit Unit_Row_Heights;
interface
{
Several test with multi-line text in Grid Header and Cells
}
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, VCLTee.Control, VCLTee.Grid,
Vcl.StdCtrls, Vcl.ExtCtrls,
VCLTee.Editor.Grid;
type
TFormRowHeights = class(TForm)
TeeGrid1: TTeeGrid;
Panel1: TPanel;
CBMultiLine: TCheckBox;
Button1: TButton;
Button2: TButton;
procedure FormCreate(Sender: TObject);
procedure CBMultiLineClick(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
FormRowHeights: TFormRowHeights;
implementation
{$R *.dfm}
uses
System.Diagnostics,
Tee.Grid.Data.Strings, Tee.Grid.Columns, Tee.Painter;
procedure TFormRowHeights.Button1Click(Sender: TObject);
begin
TTeeGridEditor.Edit(Self,TeeGrid1)
end;
procedure TFormRowHeights.Button2Click(Sender: TObject);
var t1 : TStopwatch;
t : Integer;
begin
t1:=TStopwatch.StartNew;
for t:=1 to 1000 do
TeeGrid1.Grid.Paint;
Caption:=IntToStr(t1.ElapsedMilliseconds);
end;
procedure TFormRowHeights.CBMultiLineClick(Sender: TObject);
begin
// Different row heights, depending on all row cell contents
TeeGrid1.Rows.Height.Automatic:=CBMultiLine.Checked;
// Tell data to use multi-line or not, to recalculate cell widths
// (TeeGrid1.Data as TStringsData).MultiLine:=CBMultiLine.Checked;
end;
procedure TFormRowHeights.FormCreate(Sender: TObject);
var tmp : TStringsData;
begin
tmp:=TStringsData.Create(2,11);
TeeGrid1.Data:=tmp;
TeeGrid1.Columns[0].Header.Text:='ABC'#13#10'Extra Content';
TeeGrid1.Columns[1].Header.Text:='DEF'#13#10'SubText';
tmp[0,3]:='Sample';
tmp[0,5]:='Hello'#13#10'World';
tmp[0,10]:='This is a long line'#13#10'of text with multiple'#13#10'lines';
tmp[1,1]:='Several lines'#13#10'of text';
tmp[1,6]:='More sample'#13#10'text';
tmp[1,10]:='Another long line'#10#13'of text with multiple'#10#13'lines';
TeeGrid1.Columns[1].ParentFormat:=False;
TeeGrid1.Columns[1].Format.Font.Size:=13;
TeeGrid1.Columns[1].TextAlignment:=TColumnTextAlign.Custom;
TeeGrid1.Columns[1].TextAlign.Horizontal:=THorizontalAlign.Right;
CBMultiLineClick(Self);
// Just a test, always show the vertical scrollbar
// TeeGrid1.ScrollBars.Vertical.Visible:=TScrollBarVisible.Yes;
// TeeGrid1.Columns[1].Format.Stroke.Show;
// TeeGrid1.Columns[1].Format.Stroke.Size:=4;
end;
end.
|
unit Solid.Samples.DIP.Books.Step2;
interface
uses
System.IOUtils;
type
{ TPdfBook }
TPdfBook = class
private
FPath: string;
public
constructor Create(const APath: string);
function Read: TArray<Byte>;
end;
{ TBookReader }
TBookReader = class // Simple refactoring
private
FEBook: TPdfBook;
public
constructor Create(ABook: TPdfBook);
procedure Display;
end;
implementation
{ TPdfBook }
constructor TPdfBook.Create(const APath: string);
begin
inherited Create;
FPath := APath;
end;
function TPdfBook.Read: TArray<Byte>;
begin
Result := TFile.ReadAllBytes(FPath);
end;
{ TBookReader }
constructor TBookReader.Create(ABook: TPdfBook);
begin
inherited Create;
FEBook := ABook;
end;
procedure TBookReader.Display;
var
LData: TArray<Byte>;
begin
LData := FEBook.Read;
// TODO
end;
end.
|
unit atSynchroPoint;
{* "Точка синхронизации". Для синхронизации типа "дойти до определенного места и ждать пока все не достигнут этого места". }
// Модуль: "w:\quality\test\garant6x\AdapterTest\CoreObjects\atSynchroPoint.pas"
// Стереотип: "SimpleClass"
// Элемент модели: "TatSynchroPoint" MUID: (491D9DFA0288)
interface
uses
l3IntfUses
, l3_Base
, atNamedMutex
, atSharedBuffer
, SyncObjs
;
type
PSyncData = ^TSyncData;
TSyncData = record
Total: Integer;
Waiting: Integer;
end;//TSyncData
TatSynchroPoint = class(Tl3_Base)
{* "Точка синхронизации". Для синхронизации типа "дойти до определенного места и ждать пока все не достигнут этого места". }
private
f_Mutex: TatNamedMutex;
f_SharedBuf: TatSharedBuffer;
f_SyncData: PSyncData;
f_ContinueEvent: TEvent;
private
procedure Register; virtual;
procedure Unregister; virtual;
function ContinueIfSynchronized: Boolean; virtual;
protected
procedure Cleanup; override;
{* Функция очистки полей объекта. }
public
constructor Create(const aName: AnsiString); reintroduce;
function Synchronize(aTimeOut: LongWord): Boolean; virtual;
{* Функция возвращает управление либо после успешной синхронизации (когда все дошли до вызова Synchronize), либо по истечении таймаута. В первом случае резельтат - true, во втором - false. }
end;//TatSynchroPoint
implementation
uses
l3ImplUses
, SysUtils
//#UC START# *491D9DFA0288impl_uses*
//#UC END# *491D9DFA0288impl_uses*
;
constructor TatSynchroPoint.Create(const aName: AnsiString);
//#UC START# *491DA1A60030_491D9DFA0288_var*
//#UC END# *491DA1A60030_491D9DFA0288_var*
begin
//#UC START# *491DA1A60030_491D9DFA0288_impl*
inherited Create;
//
f_Mutex := TatNamedMutex.Create(aName);
f_ContinueEvent := TEvent.Create(nil, true, false, '{DE90ACF0-3AB6-4004-B9BF-24A328D271A4}_' +aName);
// хранилище для данных синхронизации
f_SharedBuf := TatSharedBuffer.Create(aName, SizeOf(TSyncData));
f_SyncData := f_SharedBuf.Value;
// регистрируемся в точке синхронизации
Register;
//#UC END# *491DA1A60030_491D9DFA0288_impl*
end;//TatSynchroPoint.Create
function TatSynchroPoint.Synchronize(aTimeOut: LongWord): Boolean;
{* Функция возвращает управление либо после успешной синхронизации (когда все дошли до вызова Synchronize), либо по истечении таймаута. В первом случае резельтат - true, во втором - false. }
//#UC START# *491DA82B01A2_491D9DFA0288_var*
//#UC END# *491DA82B01A2_491D9DFA0288_var*
begin
//#UC START# *491DA82B01A2_491D9DFA0288_impl*
if f_Mutex.Acquire then
try
// увеличиваем количество ждущих на единицу (самого себй)
Assert(f_SyncData.Waiting >= 0, 'invalid f_SyncData.Waiting');
Inc(f_SyncData.Waiting);
// проверяем, синхронизировались ли
ContinueIfSynchronized;
finally
f_Mutex.Release;
end;
// ждем синхонизации
Result := f_ContinueEvent.WaitFor(aTimeOut) = wrSignaled;
// если не дождались то убираем себя из списка ждущих
if NOT Result then
if f_Mutex.Acquire then
try
if (f_SyncData.Waiting > 0) then
Dec(f_SyncData.Waiting);
finally
f_Mutex.Release;
end;
//#UC END# *491DA82B01A2_491D9DFA0288_impl*
end;//TatSynchroPoint.Synchronize
procedure TatSynchroPoint.Register;
//#UC START# *491DAE930239_491D9DFA0288_var*
//#UC END# *491DAE930239_491D9DFA0288_var*
begin
//#UC START# *491DAE930239_491D9DFA0288_impl*
if f_Mutex.Acquire then
try
Inc(f_SyncData.Total);
finally
f_Mutex.Release;
end;
//#UC END# *491DAE930239_491D9DFA0288_impl*
end;//TatSynchroPoint.Register
procedure TatSynchroPoint.Unregister;
//#UC START# *491DAE9E02BF_491D9DFA0288_var*
//#UC END# *491DAE9E02BF_491D9DFA0288_var*
begin
//#UC START# *491DAE9E02BF_491D9DFA0288_impl*
if f_Mutex.Acquire then
try
Dec(f_SyncData.Total);
// а теперь проверяем, может все ждали только нас, в этом случае надо отпустить всех
ContinueIfSynchronized;
finally
f_Mutex.Release;
end;
//#UC END# *491DAE9E02BF_491D9DFA0288_impl*
end;//TatSynchroPoint.Unregister
function TatSynchroPoint.ContinueIfSynchronized: Boolean;
//#UC START# *491DB4E001EF_491D9DFA0288_var*
//#UC END# *491DB4E001EF_491D9DFA0288_var*
begin
//#UC START# *491DB4E001EF_491D9DFA0288_impl*
Assert(f_SyncData.Waiting <= f_SyncData.Total, 'f_SyncData.Waiting > f_SyncData.Total !');
Result := f_SyncData.Waiting = f_SyncData.Total;
if Result then
begin // если больше некого ждать
f_ContinueEvent.SetEvent; // то поднимаем event
f_SyncData.Waiting := 0; // и обнуляем число ждущих
end
else if (f_ContinueEvent.WaitFor(0) = wrSignaled) then
f_ContinueEvent.ResetEvent; // если есть кого ждать и event не сброшен, то сбрасываем
//#UC END# *491DB4E001EF_491D9DFA0288_impl*
end;//TatSynchroPoint.ContinueIfSynchronized
procedure TatSynchroPoint.Cleanup;
{* Функция очистки полей объекта. }
//#UC START# *479731C50290_491D9DFA0288_var*
//#UC END# *479731C50290_491D9DFA0288_var*
begin
//#UC START# *479731C50290_491D9DFA0288_impl*
Unregister;
FreeAndNil(f_Mutex);
FreeAndNil(f_ContinueEvent);
FreeAndNil(f_SharedBuf);
inherited;
//#UC END# *479731C50290_491D9DFA0288_impl*
end;//TatSynchroPoint.Cleanup
end.
|
unit kwPopEditorResizeTableColumn;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Библиотека "ScriptEngine"
// Модуль: "w:/common/components/rtl/Garant/ScriptEngine/kwPopEditorResizeTableColumn.pas"
// Родные Delphi интерфейсы (.pas)
// Generated from UML model, root element: <<ScriptKeyword::Class>> Shared Delphi Scripting::ScriptEngine::EditorFromStackKeyWords::pop_editor_ResizeTableColumn
//
// Изменить размер колонки таблицы. Пример:
// {code} aDelta aCol aRow editor:ResizeTableColumn {code}
// {panel}
// * aCol - номер ячейки, которую тянем
// * aRow - номер строки
// * aDelta - смещение колонки (положительное - вправо, отрицательное - влево).
// {panel}
//
//
// Все права принадлежат ООО НПП "Гарант-Сервис".
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ! Полностью генерируется с модели. Править руками - нельзя. !
{$Include ..\ScriptEngine\seDefine.inc}
interface
{$If not defined(NoScripts)}
uses
nevTools,
evCustomEditorWindow,
tfwScriptingInterfaces,
Controls,
Classes,
l3Units,
nevGUIInterfaces
;
{$IfEnd} //not NoScripts
{$If not defined(NoScripts)}
type
{$Include ..\ScriptEngine\kwEditorFromStackTableColumnResize.imp.pas}
TkwPopEditorResizeTableColumn = class(_kwEditorFromStackTableColumnResize_)
{* Изменить размер колонки таблицы. Пример:
[code] aDelta aCol aRow editor:ResizeTableColumn [code]
[panel]
* aCol - номер ячейки, которую тянем
* aRow - номер строки
* aDelta - смещение колонки (положительное - вправо, отрицательное - влево).
[panel] }
public
// overridden public methods
class function GetWordNameForRegister: AnsiString; override;
end;//TkwPopEditorResizeTableColumn
{$IfEnd} //not NoScripts
implementation
{$If not defined(NoScripts)}
uses
Table_Const,
evConst,
TextPara_Const,
CommentPara_Const,
Windows,
evParaTools,
evOp,
tfwAutoregisteredDiction,
tfwScriptEngine,
afwFacade,
Forms,
l3Base
;
{$IfEnd} //not NoScripts
{$If not defined(NoScripts)}
type _Instance_R_ = TkwPopEditorResizeTableColumn;
{$Include ..\ScriptEngine\kwEditorFromStackTableColumnResize.imp.pas}
// start class TkwPopEditorResizeTableColumn
class function TkwPopEditorResizeTableColumn.GetWordNameForRegister: AnsiString;
{-}
begin
Result := 'pop:editor:ResizeTableColumn';
end;//TkwPopEditorResizeTableColumn.GetWordNameForRegister
{$IfEnd} //not NoScripts
initialization
{$If not defined(NoScripts)}
{$Include ..\ScriptEngine\kwEditorFromStackTableColumnResize.imp.pas}
{$IfEnd} //not NoScripts
end. |
{
$Project$
$Workfile$
$Revision$
$DateUTC$
$Id$
This file is part of the Indy (Internet Direct) project, and is offered
under the dual-licensing agreement described on the Indy website.
(http://www.indyproject.org/)
Copyright:
(c) 1993-2005, Chad Z. Hower and the Indy Pit Crew. All rights reserved.
}
{
$Log$
}
{
Rev 1.4 10/26/2004 10:33:46 PM JPMugaas
Updated refs.
Rev 1.3 2004.02.03 5:44:08 PM czhower
Name changes
Rev 1.2 24/01/2004 19:27:30 CCostelloe
Cleaned up warnings
Rev 1.1 1/21/2004 2:20:26 PM JPMugaas
InitComponent
Rev 1.0 11/13/2002 07:57:46 AM JPMugaas
}
unit IdNetworkCalculator;
interface
{$i IdCompilerDefines.inc}
uses
Classes,
IdBaseComponent,
IdStruct;
type
TNetworkClass = (
ID_NET_CLASS_A, ID_NET_CLASS_B, ID_NET_CLASS_C, ID_NET_CLASS_D, ID_NET_CLASS_E
);
const
ID_NC_MASK_LENGTH = 32;
ID_NETWORKCLASS = ID_NET_CLASS_A;
type
TIdIPAddressType = (IPLocalHost, IPLocalNetwork, IPReserved, IPInternetHost,
IPPrivateNetwork, IPLoopback, IPMulticast, IPFutureUse, IPGlobalBroadcast);
TIpProperty = class(TPersistent)
protected
FReadOnly: Boolean;
FBitArray: array[0..31] of Boolean;
FValue: array[0..3] of Byte;
FOnChange: TNotifyEvent;
function GetAddressType: TIdIPAddressType;
function GetAsBinaryString: String;
function GetAsDoubleWord: LongWord;
function GetAsString: String;
function GetBit(Index: Byte): Boolean;
function GetByte(Index: Integer): Byte;
procedure SetAsBinaryString(const Value: String);
procedure SetAsDoubleWord(const Value: LongWord);
procedure SetAsString(const Value: String);
procedure SetBit(Index: Byte; const Value: Boolean);
procedure SetByte(Index: Integer; const Value: Byte);
//
property IsReadOnly: Boolean read FReadOnly write FReadOnly default False;
public
constructor Create; virtual;
destructor Destroy; override;
//
procedure SetAll(One, Two, Three, Four: Byte); virtual;
procedure Assign(Source: TPersistent); override;
//
property Bits[Index: Byte]: Boolean read GetBit write SetBit;
property AddressType: TIdIPAddressType read GetAddressType;
property OnChange: TNotifyEvent read FOnChange write FOnChange;
published
property Byte1: Byte index 0 read GetByte write SetByte stored False;
property Byte2: Byte index 1 read GetByte write SetByte stored False;
property Byte3: Byte index 2 read GetByte write SetByte stored False;
property Byte4: Byte index 3 read GetByte write SetByte stored False;
property AsDoubleWord: LongWord read GetAsDoubleWord write SetAsDoubleWord stored False;
property AsBinaryString: String read GetAsBinaryString write SetAsBinaryString stored False;
property AsString: String read GetAsString write SetAsString;
end;
TIdNetworkCalculator = class(TIdBaseComponent)
protected
FListIP: TStrings;
FNetworkMaskLength: LongWord;
FNetworkMask: TIpProperty;
FNetworkAddress: TIpProperty;
FNetworkClass: TNetworkClass;
FOnChange: TNotifyEvent;
FOnGenIPList: TNotifyEvent;
procedure FillIPList;
function GetNetworkClassAsString: String;
function GetIsAddressRoutable: Boolean;
function GetListIP: TStrings;
procedure SetNetworkAddress(const Value: TIpProperty);
procedure SetNetworkMask(const Value: TIpProperty);
procedure SetNetworkMaskLength(const Value: LongWord);
procedure NetMaskChanged(Sender: TObject);
procedure NetAddressChanged(Sender: TObject);
procedure InitComponent; override;
public
destructor Destroy; override;
function IsAddressInNetwork(const Address: String): Boolean;
function NumIP: LongWord;
function StartIP: String;
function EndIP: String;
//
property ListIP: TStrings read GetListIP;
property NetworkClass: TNetworkClass read FNetworkClass;
property NetworkClassAsString: String read GetNetworkClassAsString;
property IsAddressRoutable: Boolean read GetIsAddressRoutable;
published
property NetworkAddress: TIpProperty read FNetworkAddress write SetNetworkAddress;
property NetworkMask: TIpProperty read FNetworkMask write SetNetworkMask;
property NetworkMaskLength: LongWord read FNetworkMaskLength write SetNetworkMaskLength
default ID_NC_MASK_LENGTH;
property OnGenIPList: TNotifyEvent read FOnGenIPList write FOnGenIPList;
property OnChange: TNotifyEvent read FOnChange write FOnChange;
end;
implementation
uses
IdException, IdGlobal, IdGlobalProtocols, IdResourceStringsProtocols, IdStack, SysUtils;
function MakeLongWordIP(const One, Two, Three, Four: Byte): LongWord;
begin
Result := (LongWord(One) shl 24) or (LongWord(Two) shl 16) or (LongWord(Three) shl 8) or LongWord(Four);
end;
procedure BreakupLongWordIP(const Value: LongWord; var One, Two, Three, Four: Byte);
begin
One := Byte((Value and $FF000000) shr 24);
Two := Byte((Value and $00FF0000) shr 16);
Three := Byte((Value and $0000FF00) shr 8);
Four := Byte(Value and $000000FF);
end;
function StrToIP(const Value: string): LongWord;
var
strBuffers: Array [0..3] of String;
cardBuffers: Array[0..3] of LongWord;
StrWork: String;
I: Integer;
begin
StrWork := Value;
// Separate the strings
strBuffers[0] := Fetch(StrWork, '.', True); {Do not Localize}
strBuffers[1] := Fetch(StrWork, '.', True); {Do not Localize}
strBuffers[2] := Fetch(StrWork, '.', True); {Do not Localize}
strBuffers[3] := StrWork;
try
for I := 0 to 3 do begin
cardBuffers[I] := IndyStrToInt(strBuffers[I]);
end;
except
on E: exception do begin
raise EIdException.CreateFmt(RSNETCALInvalidIPString, [Value]);
end;
end;
// range check
for I := 0 to 3 do begin
if not (cardBuffers[I] in [0..255]) then begin
raise EIdException.CreateFmt(RSNETCALInvalidIPString, [Value]);
end;
end;
Result := MakeLongWordIP(cardBuffers[0], cardBuffers[1], cardBuffers[2], cardBuffers[3]);
end;
{ TIdNetworkCalculator }
procedure TIdNetworkCalculator.InitComponent;
begin
inherited InitComponent;
FNetworkMask := TIpProperty.Create;
FNetworkMask.OnChange := NetMaskChanged;
FNetworkAddress := TIpProperty.Create;
FNetworkAddress.OnChange := NetAddressChanged;
FListIP := TStringList.Create;
FNetworkClass := ID_NETWORKCLASS;
NetworkMaskLength := ID_NC_MASK_LENGTH;
end;
destructor TIdNetworkCalculator.Destroy;
begin
FreeAndNil(FNetworkMask);
FreeAndNil(FNetworkAddress);
FreeAndNil(FListIP);
inherited Destroy;
end;
procedure TIdNetworkCalculator.FillIPList;
var
i: LongWord;
BaseIP: LongWord;
LByte1, LByte2, LByte3, LByte4: Byte;
begin
if FListIP.Count = 0 then
begin
// prevent to start a long loop in the IDE (will lock delphi)
if IsDesignTime and (NumIP > 1024) then begin
FListIP.text := IndyFormat(RSNETCALConfirmLongIPList, [NumIP]);
end else
begin
BaseIP := NetworkAddress.AsDoubleWord and NetworkMask.AsDoubleWord;
// Lock the list so we won't be "repainting" the whole time... {Do not Localize}
FListIP.BeginUpdate;
try
FListIP.Capacity := NumIP;
for i := 1 to (NumIP - 1) do
begin
Inc(BaseIP);
BreakupLongWordIP(BaseIP, LByte1, LByte2, LByte3, LByte4);
FListIP.Append(IndyFormat('%d.%d.%d.%d', [LByte1, LByte2, LByte3, LByte4])); {Do not Localize}
end;
finally
FListIP.EndUpdate;
end;
end;
end;
end;
function TIdNetworkCalculator.GetListIP: TStrings;
begin
FillIPList;
Result := FListIP;
end;
function TIdNetworkCalculator.IsAddressInNetwork(const Address: String): Boolean;
begin
Result := (StrToIP(Address) and NetworkMask.AsDoubleWord) = (NetworkAddress.AsDoubleWord and NetworkMask.AsDoubleWord);
end;
procedure TIdNetworkCalculator.NetAddressChanged(Sender: TObject);
var
sBuffer: String;
begin
FListIP.Clear;
sBuffer := NetworkAddress.AsBinaryString;
// RFC 1365
if TextStartsWith(sBuffer, '0') then begin {Do not Localize}
fNetworkClass := ID_NET_CLASS_A;
end
else if TextStartsWith(sBuffer, '10') then begin {Do not Localize}
fNetworkClass := ID_NET_CLASS_B;
end
else if TextStartsWith(sBuffer, '110') then begin {Do not Localize}
fNetworkClass := ID_NET_CLASS_C;
end
// Network class D is reserved for multicast
else if TextStartsWith(sBuffer, '1110') then begin {Do not Localize}
fNetworkClass := ID_NET_CLASS_D;
end
// network class E is reserved and shouldn't be used {Do not Localize}
else {if TextStartsWith(sBuffer, '1111') then} begin {Do not Localize}
fNetworkClass := ID_NET_CLASS_E;
end;
if Assigned(FOnChange) then begin
FOnChange(Self);
end;
end;
procedure TIdNetworkCalculator.NetMaskChanged(Sender: TObject);
var
sBuffer: string;
InitialMaskLength: LongWord;
begin
FListIP.Clear;
InitialMaskLength := FNetworkMaskLength;
// A network mask MUST NOT contains holes.
sBuffer := FNetworkMask.AsBinaryString;
while TextStartsWith(sBuffer, '1') do begin {Do not Localize}
Delete(sBuffer, 1, 1);
end;
if IndyPos('1', sBuffer) > 0 then {Do not Localize}
begin
NetworkMaskLength := InitialMaskLength;
raise EIdException.Create(RSNETCALCInvalidNetworkMask); // 'Invalid network mask' {Do not Localize}
end;
// set the net mask length
NetworkMaskLength := 32 - Length(sBuffer);
if Assigned(FOnChange) then begin
FOnChange(Self);
end;
end;
procedure TIdNetworkCalculator.SetNetworkAddress(const Value: TIpProperty);
begin
FNetworkAddress.Assign(Value);
end;
procedure TIdNetworkCalculator.SetNetworkMask(const Value: TIpProperty);
begin
FNetworkMask.Assign(Value);
end;
procedure TIdNetworkCalculator.SetNetworkMaskLength(const Value: LongWord);
var
LBuffer, LValue: LongWord;
begin
if Value <= 32 then begin
LValue := Value;
end else begin
LValue := 32;
end;
if FNetworkMaskLength <> LValue then
begin
FNetworkMaskLength := LValue;
if Value > 0 then begin
LBuffer := High(LongWord) shl (32 - LValue);
end else begin
LBuffer := 0;
end;
FNetworkMask.AsDoubleWord := LBuffer;
end;
end;
function TIdNetworkCalculator.GetNetworkClassAsString: String;
const
sClasses: array[TNetworkClass] of String = ('A', 'B', 'C', 'D','E'); {Do not Localize}
begin
Result := sClasses[FNetworkClass];
end;
function TIdNetworkCalculator.GetIsAddressRoutable: Boolean;
begin
// RFC 1918
with NetworkAddress do
begin
Result := not (
(Byte1 = 10) or
((Byte1 = 172) and (Byte2 in [16..31])) or
((Byte1 = 192) and (Byte2 = 168))
);
end;
end;
function TIdNetworkCalculator.EndIP: String;
var
IP: LongWord;
LByte1, LByte2, LByte3, LByte4: Byte;
begin
IP := (NetworkAddress.AsDoubleWord and NetworkMask.AsDoubleWord) + (NumIP - 1);
BreakupLongWordIP(IP, LByte1, LByte2, LByte3, LByte4);
Result := IndyFormat('%d.%d.%d.%d', [LByte1, LByte2, LByte3, LByte4]); {Do not Localize}
end;
function TIdNetworkCalculator.NumIP: LongWord;
begin
Result := 1 shl (32 - NetworkMaskLength);
end;
function TIdNetworkCalculator.StartIP: String;
var
IP: LongWord;
LByte1, LByte2, LByte3, LByte4: Byte;
begin
IP := NetworkAddress.AsDoubleWord and NetworkMask.AsDoubleWord;
BreakupLongWordIP(IP, LByte1, LByte2, LByte3, LByte4);
Result := IndyFormat('%d.%d.%d.%d', [LByte1, LByte2, LByte3, LByte4]); {Do not Localize}
end;
{ TIpProperty }
constructor TIpProperty.Create;
begin
inherited Create;
FValue[0] := $0;
FValue[1] := $0;
FValue[2] := $0;
FValue[3] := $0;
end;
destructor TIpProperty.Destroy;
begin
inherited Destroy;
end;
procedure TIpProperty.Assign(Source: TPersistent);
begin
if Source is TIpProperty then
begin
with Source as TIpProperty do begin
Self.SetAll(Byte1, Byte2, Byte3, Byte4);
end;
end else begin
inherited Assign(Source);
end;
end;
function TIpProperty.GetBit(Index: Byte): boolean;
begin
Result := FBitArray[index];
end;
procedure TIpProperty.SetAll(One, Two, Three, Four: Byte);
var
i, j: Integer;
begin
if (FValue[0] <> One) or (FValue[1] <> Two) or (FValue[2] <> Three) or (FValue[3] <> Four) then
begin
FValue[0] := One;
FValue[1] := Two;
FValue[2] := Three;
FValue[3] := Four;
// set the binary array
for i := 0 to 3 do begin
for j := 0 to 7 do begin
FBitArray[(8*i)+j] := (FValue[i] and (1 shl (7-j))) <> 0;
end;
end;
if Assigned(FOnChange) then begin
FOnChange(Self);
end;
end;
end;
function TIpProperty.GetAsBinaryString: String;
var
i : Integer;
begin
// get the binary string
SetLength(Result, 32);
for i := 1 to 32 do
begin
if FBitArray[i-1] then begin
Result[i] := '1' {Do not Localize}
end else begin
Result[i] := '0'; {Do not Localize}
end;
end;
end;
function TIpProperty.GetAsDoubleWord: LongWord;
begin
Result := MakeLongWordIP(FValue[0], FValue[1], FValue[2], FValue[3]);
end;
function TIpProperty.GetAsString: String;
begin
// Set the string
Result := IndyFormat('%d.%d.%d.%d', [FValue[0], FValue[1], FValue[2], FValue[3]]); {Do not Localize}
end;
procedure TIpProperty.SetAsBinaryString(const Value: String);
var
i: Integer;
NewIP: LongWord;
begin
if IsReadOnly then begin
Exit;
end;
if Length(Value) <> 32 then begin
raise EIdException.Create(RSNETCALCInvalidValueLength) // 'Invalid value length: Should be 32.' {Do not Localize}
end;
if not TextIsSame(Value, AsBinaryString) then
begin
NewIP := 0;
for i := 1 to 32 do
begin
if Value[i] <> '0' then begin {Do not Localize}
NewIP := NewIP or (1 shl (32 - i));
end;
end;
SetAsDoubleWord(NewIP);
end;
end;
function TIpProperty.GetByte(Index: Integer): Byte;
begin
Result := FValue[Index];
end;
procedure TIpProperty.SetAsDoubleWord(const Value: LongWord);
var
LByte1, LByte2, LByte3, LByte4: Byte;
begin
if not IsReadOnly then
begin
BreakupLongWordIP(Value, LByte1, LByte2, LByte3, LByte4);
SetAll(LByte1, LByte2, LByte3, LByte4);
end;
end;
procedure TIpProperty.SetAsString(const Value: String);
begin
SetAsDoubleWord(StrToIP(Value));
end;
procedure TIpProperty.SetBit(Index: Byte; const Value: Boolean);
var
ByteIndex: Integer;
BitValue: Byte;
begin
if (not IsReadOnly) and (FBitArray[Index] <> Value) then
begin
FBitArray[Index] := Value;
ByteIndex := Index div 8;
BitValue := Byte(1 shl (7-(Index mod 8)));
if Value then begin
FValue[ByteIndex] := FValue[ByteIndex] or BitValue;
end else begin
FValue[ByteIndex] := FValue[ByteIndex] and not BitValue;
end;
if Assigned(OnChange) then begin
OnChange(Self);
end;
end;
end;
procedure TIpProperty.SetByte(Index: Integer; const Value: Byte);
begin
if (not IsReadOnly) and (GetByte(Index) <> Value) then
begin
case Index of
0: SetAll(Value, Byte2, Byte3, Byte4);
1: SetAll(Byte1, Value, Byte3, Byte4);
2: SetAll(Byte1, Byte2, Value, Byte4);
3: SetAll(Byte1, Byte2, Byte3, Value);
end;
end;
end;
function TIpProperty.GetAddressType: TIdIPAddressType;
// based on http://www.ora.com/reference/dictionary/terms/I/IP_Address.htm
begin
Result := IPInternetHost;
case Byte1 of
{localhost or local network}
0 : if AsDoubleWord = 0 then begin
Result := IPLocalHost;
end else begin
Result := IPLocalNetwork;
end;
{Private network allocations}
10 : Result := IPPrivateNetwork;
172 : if Byte2 = 16 then begin
Result := IPPrivateNetwork;
end;
192 : if Byte2 = 168 then begin
Result := IPPrivateNetwork;
end
else if (Byte2 = 0) and (Byte3 = 0) then begin
Result := IPReserved;
end;
{loopback}
127 : Result := IPLoopback;
255 : if AsDoubleWord = $FFFFFFFF then begin
Result := IPGlobalBroadcast;
end else begin
Result := IPFutureUse;
end;
{Reserved}
128 : if Byte2 = 0 then begin
Result := IPReserved;
end;
191 : if (Byte2 = 255) and (Byte3 = 255) then begin
Result := IPReserved;
end;
223 : if (Byte2 = 255) and (Byte3 = 255) then begin
Result := IPReserved;
end;
{Multicast}
224..239: Result := IPMulticast;
{Future Use}
240..254: Result := IPFutureUse;
end;
end;
end.
|
unit d_DateEdit;
{ $Id: d_DateEdit.pas,v 1.2 2005/03/28 14:02:16 voba Exp $ }
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
BottomBtnDlg, StdCtrls, Buttons, ExtCtrls,
stDate, Mask, vtCombo, vtDateEdit, vtBndLabel;
type
TDateEditDlg = class(TBottomBtnDlg)
edtDate: TvtDateEdit;
lblText: TvtBoundedLabel;
private
function GetValue : TstDate;
procedure SetValue(aValue : TstDate);
procedure SetLabelText(aValue : string);
public
property Date : TstDate read GetValue write SetValue;
property LabelText : string write SetLabelText;
end;
function RequestDate(var aValue : TstDate; AOwner: TComponent;
aCaption : String = ''; aLabel : String = '') : Boolean;
implementation
{$R *.DFM}
function RequestDate(var aValue : TstDate; AOwner: TComponent;
aCaption : String = ''; aLabel : String = '') : Boolean;
begin
With TDateEditDlg.Create(AOwner) do
try
Caption := aCaption;
LabelText := aLabel;
if Length(aLabel) > 10 then
begin
edtDate.Top := 34;
edtDate.Left := 16;
lblText.Position := lpAbove;
end;
Date := aValue;
Result := Execute;
if Result then
aValue := Date;
finally
Free;
end;
end;
function TDateEditDlg.GetValue : TstDate;
begin
Result := edtDate.StDate;
end;
procedure TDateEditDlg.SetValue(aValue : TstDate);
begin
edtDate.StDate := aValue;
end;
procedure TDateEditDlg.SetLabelText(aValue : String);
begin
lblText.Caption := aValue;
end;
end.
|
{ Subroutine SST_W_C_SMENT_END
*
* Write the end of the statement. This will cause the semicolon statement
* terminator to be written. The indentation level will be restored by
* decreasing it one level. This is compatible with what was done in
* subroutine SST_W_C_SMENT_START.
*
* The state for the parent statement will be popped from the stack.
}
module sst_w_c_SMENT_END;
define sst_w_c_sment_end;
%include 'sst_w_c.ins.pas';
procedure sst_w_c_sment_end; {indicate done writing a statement}
begin
sst_w_c_sment_end_nclose; {end the statement and restore/pop state}
sst_w.appendn^ (';', 1); {write semicolon statement terminator}
sst_w.line_close^; {end the current output line}
end;
|
{*******************************************************}
{ Проект: Repository }
{ Модуль: uReportListImpl.pas }
{ Описание: Реализация IReportList }
{ Copyright (C) 2015 Боборыкин В.В. (bpost@yandex.ru) }
{ }
{ Распространяется по лицензии GPLv3 }
{*******************************************************}
unit uReportListImpl;
interface
uses
SysUtils, Classes, uServices;
function CreateReportTemplate: IReportTemplate;
function CreateReportList: IReportList;
implementation
type
TReportListItem = class(TInterfacedObject, IReportListItem)
private
FName: string;
public
function GetName: string; stdcall;
procedure SetName(const Value: string); stdcall;
property Name: string read GetName write SetName;
end;
TReportTemplate = class(TReportListItem, IReportTemplate)
private
FTemplateFileName: string;
public
function GetTemplateFileName: string; stdcall;
procedure SetTemplateFileName(const Value: string); stdcall;
property TemplateFileName: string read GetTemplateFileName write
SetTemplateFileName;
end;
TReportList = class(TReportListItem, IReportList)
private
FItems: IInterfaceList;
public
constructor Create;
function Add(AItem: IReportListItem): Integer; stdcall;
procedure Delete(Index: Integer); stdcall;
function GetCount: Integer; stdcall;
function GetItems(Index: Integer): IReportListItem; stdcall;
procedure SetItems(Index: Integer; Value: IReportListItem); stdcall;
property Count: Integer read GetCount;
property Items[Index: Integer]: IReportListItem read GetItems write
SetItems;
end;
{
******************************* TReportListItem ********************************
}
function TReportListItem.GetName: string;
begin
Result := FName;
end;
procedure TReportListItem.SetName(const Value: string);
begin
if FName <> Value then
begin
FName := Value;
end;
end;
{
******************************* TReportTemplate ********************************
}
function TReportTemplate.GetTemplateFileName: string;
begin
Result := FTemplateFileName;
end;
procedure TReportTemplate.SetTemplateFileName(const Value: string);
begin
if FTemplateFileName <> Value then
begin
FTemplateFileName := Value;
end;
end;
{
********************************* TReportList **********************************
}
constructor TReportList.Create;
begin
inherited Create;
FItems := TInterfaceList.Create();
end;
function TReportList.Add(AItem: IReportListItem): Integer;
begin
Result := FItems.Add(AItem)
end;
procedure TReportList.Delete(Index: Integer);
begin
FItems.Delete(Index);
end;
function TReportList.GetCount: Integer;
begin
Result := FItems.Count
end;
function TReportList.GetItems(Index: Integer): IReportListItem;
begin
Supports(FItems[Index], IReportListItem, Result);
end;
procedure TReportList.SetItems(Index: Integer; Value: IReportListItem);
begin
FItems[Index] := Value;
end;
function CreateReportTemplate: IReportTemplate;
begin
Result := TReportTemplate.Create;
end;
function CreateReportList: IReportList;
begin
Result := TReportList.Create;
end;
end.
|
unit fmuSlipConfigure;
interface
uses
// VCL
Windows, ExtCtrls, Classes, Controls, StdCtrls, Buttons, SysUtils,
Grids, ValEdit, Dialogs,
// This
untPages, untDriver, untTypes, untUtil, untTestParams;
type
{ TfmSlipConfigure }
TfmSlipConfigure = class(TPage)
btnConfigureStandardSlipDocument: TBitBtn;
btnConfigureSlipDocument: TBitBtn;
vleParams: TValueListEditor;
btnLoadFromTables: TButton;
btnDefaultValues: TButton;
btnSaveToTables: TButton;
procedure btnConfigureSlipDocumentClick(Sender: TObject);
procedure btnConfigureStandardSlipDocumentClick(Sender: TObject);
procedure btnLoadFromTablesClick(Sender: TObject);
procedure btnDefaultValuesClick(Sender: TObject);
procedure btnSaveToTablesClick(Sender: TObject);
procedure vleParamsSetEditText(Sender: TObject; ACol, ARow: Integer;
const Value: String);
procedure FormResize(Sender: TObject);
private
function GetItem(const AName: string): Integer;
function LoadFromTables: Integer;
function SaveToTables: Integer;
public
procedure UpdateObject; override;
procedure Initialize; override;
end;
implementation
{$R *.DFM}
const
C_SlipDocumentWidth = 'Ширина';
C_SlipDocumentLength = 'Длина';
C_PrintingAlignment = 'Ориентация';
const
ConfigureSlipParams: array[0..2] of TIntParam =(
(Name: C_SlipDocumentWidth; Value: 0),
(Name: C_SlipDocumentLength; Value: 0),
(Name: C_PrintingAlignment; Value: 0)
);
{ TfmSlipConfigure }
procedure TfmSlipConfigure.btnConfigureSlipDocumentClick(Sender: TObject);
begin
EnableButtons(False);
try
UpdateObject;
Check(Driver.ConfigureSlipDocument);
finally
EnableButtons(True);
end;
end;
procedure TfmSlipConfigure.btnConfigureStandardSlipDocumentClick(Sender: TObject);
begin
EnableButtons(False);
try
Check(Driver.ConfigureStandardSlipDocument);
finally
EnableButtons(True);
end;
end;
procedure TfmSlipConfigure.Initialize;
var
i: Integer;
begin
for i := Low(ConfigureSlipParams) to High(ConfigureSlipParams) - 1 do
VLE_AddProperty(vleParams, ConfigureSlipParams[i].Name, IntToStr(ConfigureSlipParams[i].Value) );
VLE_AddPickProperty(vleParams, C_PrintingAlignment, '0',
['0', '90', '180', '270'], [0, 1, 2, 3]);
for i := 1 to 199 do
VLE_AddProperty(vleParams, Format('Межстрочный интервал между строками: %d и %d',
[i, i + 1]), '24');
// Если были загружены настройки, записываем их в контрол
if TestParams.ParamsLoaded then
StringToVLEParams(vleParams, TestParams.SlipConfigure.Text)
else
TestParams.SlipConfigure.Text := VLEParamsToString(vleParams);
end;
function TfmSlipConfigure.LoadFromTables: Integer;
var
i: Integer;
begin
EnableButtons(False);
try
Driver.TableNumber := 10;
Result := Driver.GetTableStruct;
if Result <> 0 then Exit;
Driver.RowNumber := 1;
for i := 1 to 3 do
begin
Driver.FieldNumber := i;
Result := Driver.ReadTable;
if Result = 0 then
begin
if i = 3 then
VLE_SETPickPropertyValue(vleParams, C_PrintingAlignment, Driver.ValueOfFieldInteger)
else
vleParams.Cells[1, i] := IntToSTr(Driver.ValueOfFieldInteger);
end;
end;
Driver.TableNumber := 11;
Result := Driver.GetTableStruct;
if Result <> 0 then Exit;
Driver.FieldNumber := 1;
for i := 1 to Driver.RowNumber do
begin
Driver.RowNumber := i;
Result := Driver.ReadTable;
if Result = 0 then
vleParams.Cells[1, i + 3] := IntToSTr(Driver.ValueOfFieldInteger);
end;
Updatepage;
finally
EnableButtons(True);
end;
end;
procedure TfmSlipConfigure.UpdateObject;
var
S: string;
i: Integer;
begin
Driver.SlipDocumentWidth := GetItem(C_SlipDocumentWidth);
Driver.SlipDocumentLength := GetItem(C_SlipDocumentLength);
Driver.PrintingAlignment := VLE_GetPickPropertyValue(vleParams, C_PrintingAlignment);
S := '';
for i := 1 to 199 do
S := S + Chr(StrToInt(Trim(vleParams.Cells[1, i + 3])));
Driver.SlipStringIntervals := S;
end;
function TfmSlipConfigure.GetItem(const AName: string): Integer;
begin
Result := StrToInt(VLE_GetPropertyValue(vleParams, AName));
end;
procedure TfmSlipConfigure.btnLoadFromTablesClick(Sender: TObject);
begin
Check(LoadFromTables);
end;
procedure TfmSlipConfigure.btnDefaultValuesClick(Sender: TObject);
begin
vleParams.Strings.Text := '';
Initialize;
end;
procedure TfmSlipConfigure.btnSaveToTablesClick(Sender: TObject);
begin
Check(SaveToTables);
end;
function TfmSlipConfigure.SaveToTables: Integer;
var
i: Integer;
begin
EnableButtons(False);
try
Driver.TableNumber := 10;
Result := Driver.GetTableStruct;
if Result <> 0 then Exit;
Driver.RowNumber := 1;
for i := 1 to 3 do
begin
Driver.FieldNumber := i;
if i = 3 then
Driver.ValueOfFieldInteger := VLE_GetPickPropertyValue(vleParams, C_PrintingAlignment)
else
Driver.ValueOfFieldInteger := StrToInt(vleParams.Cells[1, i]);
Result := Driver.WriteTable;
if Result <> 0 then Exit;
end;
Driver.TableNumber := 11;
Result := Driver.GetTableStruct;
if Result <> 0 then Exit;
Driver.FieldNumber := 1;
for i := 1 to Driver.RowNumber do
begin
Driver.RowNumber := i;
Driver.ValueOfFieldInteger := StrToInt(vleParams.Cells[1, i + 3]);
Result := Driver.WriteTable;
if Result <> 0 then Exit;
end;
Updatepage;
finally
EnableButtons(True);
end;
end;
procedure TfmSlipConfigure.vleParamsSetEditText(Sender: TObject; ACol,
ARow: Integer; const Value: String);
begin
TestParams.SlipConfigure.Text := VLEParamsToString(vleParams);
end;
procedure TfmSlipConfigure.FormResize(Sender: TObject);
begin
if vleParams.Width > 392 then
vleParams.DisplayOptions := vleParams.DisplayOptions + [doAutoColResize]
else
vleParams.DisplayOptions := vleParams.DisplayOptions - [doAutoColResize];
end;
end.
|
unit MDIChilds.ProgressForm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics,
Controls, Forms, Dialogs, ComCtrls, StdCtrls, ExtCtrls;
type
TFmProgress = class(TForm)
Bevel: TBevel;
btnBreak: TButton;
lblProcessCaption: TLabel;
PB: TProgressBar;
procedure FormCreate(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
private
FInProcess: Boolean;
function GetProcessCaption: string;
procedure SetProcessCaption(Value: string);
procedure DoBreak(Sender: TObject); virtual;
public
procedure InitPB(Max: Integer);
procedure StepIt(Caption: string);
property InProcess: Boolean read FInProcess write FInProcess;
property ProcessCaption: string read GetProcessCaption write SetProcessCaption;
end;
var
FmProgress: TFmProgress;
implementation
{$R *.dfm}
{ TForm1 }
procedure TFmProgress.DoBreak(Sender: TObject);
begin
FInProcess := False;
Application.MessageBox(PChar('Обработка прервана пользователем'), PChar(Application.Title), 0);
Close;
end;
procedure TFmProgress.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
CanClose := not FInProcess;
end;
procedure TFmProgress.FormCreate(Sender: TObject);
begin
lblProcessCaption.Caption := EmptyStr;
PB.Step := 1;
FInProcess := True;
btnBreak.OnClick := DoBreak;
end;
function TFmProgress.GetProcessCaption: string;
begin
Result := lblProcessCaption.Caption;
end;
procedure TFmProgress.InitPB(Max: Integer);
begin
PB.Position := 0;
PB.Min := 0;
PB.Max := Max;
end;
procedure TFmProgress.SetProcessCaption(Value: string);
begin
lblProcessCaption.Caption := Value;
end;
procedure TFmProgress.StepIt(Caption: string);
begin
SetProcessCaption(Caption);
PB.StepIt;
Application.ProcessMessages;
end;
end.
|
(*
JCore WebServices, Embedded HTTP Server Application Handler Classes
Copyright (C) 2015 Joao Morais
See the file LICENSE.txt, included in this distribution,
for details about the copyright.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*)
unit JCoreWSHTTPServerApp;
{$I jcore.inc}
interface
uses
Classes,
HTTPDefs,
custweb,
custhttpapp,
JCoreWSIntf,
JCoreWSRequest;
type
{ TJCoreWSFCLHTTPHandler }
{** @exclude }
TJCoreWSFCLHTTPHandler = class(TFPHTTPServerHandler)
private
FRequestRouter: IJCoreWSRequestRouter;
public
constructor Create(AOwner: TComponent); override;
procedure HandleRequest(ARequest: TRequest; AResponse: TResponse); override;
end;
{ TJCoreWSFCLHTTPApp }
{** @exclude }
TJCoreWSFCLHTTPApp = class(TCustomHTTPApplication)
protected
function InitializeWebHandler: TWebHandler; override;
end;
{ TJCoreWSHTTPServerHandler }
TJCoreWSHTTPServerHandler = class(TInterfacedObject, IJCoreWSApplicationHandler)
private
FHTTPApp: TJCoreWSFCLHTTPApp;
FParams: TStrings;
public
destructor Destroy; override;
function Params: TStrings;
procedure Run;
end;
implementation
uses
sysutils,
JCoreDIC;
{ TJCoreWSFCLHTTPHandler }
constructor TJCoreWSFCLHTTPHandler.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
TJCoreDIC.Locate(IJCoreWSRequestRouter, FRequestRouter);
end;
procedure TJCoreWSFCLHTTPHandler.HandleRequest(ARequest: TRequest; AResponse: TResponse);
begin
FRequestRouter.RouteRequest(ARequest, AResponse);
end;
{ TJCoreWSFCLHTTPApp }
function TJCoreWSFCLHTTPApp.InitializeWebHandler: TWebHandler;
begin
Result := TJCoreWSFCLHTTPHandler.Create(Self);
end;
{ TJCoreWSHTTPServerHandler }
destructor TJCoreWSHTTPServerHandler.Destroy;
begin
FreeAndNil(FParams);
FreeAndNil(FHTTPApp);
inherited Destroy;
end;
function TJCoreWSHTTPServerHandler.Params: TStrings;
begin
if not Assigned(FParams) then
begin
FParams := TStringList.Create;
FParams.Values['Title'] := 'httpserver';
FParams.Values['Port'] := '8080';
FParams.Values['Threaded'] := 'True';
end;
Result := FParams;
end;
procedure TJCoreWSHTTPServerHandler.Run;
begin
FreeAndNil(FHTTPApp);
FHTTPApp := TJCoreWSFCLHTTPApp.Create(nil);
FHTTPApp.Title := Params.Values['Title'];
FHTTPApp.Port := StrToInt(Params.Values['Port']);
FHTTPApp.Threaded := SameText(Params.Values['Threaded'], 'True');
FHTTPApp.Initialize;
FHTTPApp.Run;
end;
initialization
TJCoreDIC.Register(IJCoreWSApplicationHandler, 'HTTP', TJCoreWSHTTPServerHandler, jdsApplication);
finalization
TJCoreDIC.Unregister(IJCoreWSApplicationHandler, TJCoreWSHTTPServerHandler);
end.
|
Program Aufgabe1;
{$codepage utf8}
Var Zahl: Integer;
ZahlMod2: Integer;
Begin
Write('Bitte gib eine Zahl ein: ');
Read(Zahl);
ZahlMod2 := Zahl Mod 2;
If ZahlMod2 = 0 Then
Begin
WriteLn('Die eingegebene Zahl ist gerade.');
End Else Begin
WriteLn('Die eingegebene Zahl ist ungerade.');
End;
End. |
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls;
type
TATMissedPoint = (
ampnTopLeft,
ampnTopRight,
ampnBottomLeft,
ampnBottomRight
);
type
{ TForm1 }
TForm1 = class(TForm)
chkAntialias: TCheckBox;
chkShowBorder: TCheckBox;
ImageList1: TImageList;
ImageList2: TImageList;
Panel1: TPanel;
procedure chkShowBorderChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Panel1Paint(Sender: TObject);
private
b, b0: TBitmap;
procedure DrawTriangleRectFramed(C: TCanvas; AX, AY, ASizeX, ASizeY,
AScale: integer; ATriKind: TATMissedPoint; AColorFill,
AColorLine: TColor; bmp: TBitmap);
procedure PaintBitmap;
public
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Panel1Paint(Sender: TObject);
begin
b.SetSize(Panel1.Width, Panel1.Height);
PaintBitmap;
Panel1.Canvas.Draw(0, 0, b);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
b:= TBitmap.Create;
b0:= TBitmap.Create;
end;
procedure TForm1.chkShowBorderChange(Sender: TObject);
begin
Panel1.Invalidate;
end;
procedure CanvasStretchDraw(C: TCanvas; const R: TRect; Bmp: TBitmap); {$ifdef fpc}inline;{$endif}
begin
{$ifdef fpc}
C.StretchDraw(R, Bmp);
{$else}
//Delphi: StretchDraw cannot draw smooth
StretchBlt(
C.Handle, R.Left, R.Top, R.Right-R.Left, R.Bottom-R.Top,
Bmp.Canvas.Handle, 0, 0, Bmp.Width, Bmp.Height,
C.CopyMode);
{$endif}
end;
procedure TForm1.DrawTriangleRectFramed(C: TCanvas;
AX, AY, ASizeX, ASizeY, AScale: integer;
ATriKind: TATMissedPoint;
AColorFill, AColorLine: TColor;
bmp: TBitmap);
var
p0, p1, p2, p3: TPoint;
line1, line2: TPoint;
ar: array[0..2] of TPoint;
begin
bmp.SetSize(ASizeX*AScale, ASizeY*AScale);
p0:= Point(0, 0);
p1:= Point(bmp.Width, 0);
p2:= Point(0, bmp.Height);
p3:= Point(bmp.Width, bmp.Height);
case ATriKind of
ampnTopLeft: begin ar[0]:= p1; ar[1]:= p2; ar[2]:= p3; line1:= p1; line2:= p2; end;
ampnTopRight: begin ar[0]:= p0; ar[1]:= p2; ar[2]:= p3; line1:= p0; line2:= p3; end;
ampnBottomLeft: begin ar[0]:= p0; ar[1]:= p1; ar[2]:= p3; line1:= p0; line2:= p3; end;
ampnBottomRight: begin ar[0]:= p0; ar[1]:= p1; ar[2]:= p2; line1:= p1; line2:= p2; end;
end;
//bmp.Canvas.Brush.Color:= AColorBG;
//bmp.Canvas.FillRect(0, 0, bmp.Width, bmp.Height);
bmp.Canvas.CopyRect(
Rect(0, 0, bmp.Width, bmp.Height),
C,
Rect(AX, AY, AX+ASizeX, AY+ASizeY)
);
bmp.Canvas.Pen.Style:= psClear;
bmp.Canvas.Brush.Color:= AColorFill;
bmp.Canvas.Polygon(ar);
if chkShowBorder.Checked then
bmp.Canvas.Pen.Style:= psSolid
else
bmp.Canvas.Pen.Style:= psClear;
bmp.Canvas.Pen.Color:= AColorLine;
bmp.Canvas.Pen.Width:= AScale;
bmp.Canvas.MoveTo(line1.X, line1.Y);
bmp.Canvas.LineTo(line2.X, line2.Y);
bmp.Canvas.Pen.Width:= 1;
CanvasStretchDraw(C, Rect(AX, AY, AX+ASizeX, AY+ASizeY), bmp);
end;
procedure TForm1.PaintBitmap;
const
cell = 10;
dx = 5;
var
c: tcanvas;
i: integer;
begin
c:= b.canvas;
if chkAntialias.Checked then
c.AntialiasingMode:= amOn
else
c.AntialiasingMode:= amOff;
c.Brush.Color:= clMoneyGreen;
c.FillRect(0, 0, b.Width, b.Height);
c.Font.Size:= 20;
c.Font.Color:= clRed;
c.Brush.Style:= bsClear;
c.TextOut(2, 0, 'Background_Red');
c.Font.Color:= clBlue;
c.Brush.Style:= bsClear;
c.TextOut(2, 24, 'Background_Blue');
c.Font.Color:= clGreen;
c.Brush.Style:= bsClear;
c.TextOut(2, 48, 'Background_Green');
Imagelist1.Draw(c, 2, 8, 0);
Imagelist1.Draw(c, 20, 8, 1);
Imagelist2.Draw(c, 2, 30, 0);
Imagelist2.Draw(c, 30, 30, 1);
DrawTriangleRectFramed(c,
0, 60, 40, 40,
5,
ampnTopLeft,
clYellow,
clPurple,
b0
);
DrawTriangleRectFramed(c,
60, 60, 40, 40,
5,
ampnTopRight,
clYellow,
clPurple,
b0
);
DrawTriangleRectFramed(c,
0, 120, 40, 40,
5,
ampnBottomLeft,
clYellow,
clPurple,
b0
);
DrawTriangleRectFramed(c,
60, 120, 40, 40,
5,
ampnBottomRight,
clYellow,
clPurple,
b0
);
if chkShowBorder.Checked then
c.Pen.Style:= psSolid
else
c.Pen.Style:= psClear;
c.Font.Color:= clPurple;
c.Font.Size:= 8;
c.Brush.Style:= bsSolid;
c.Brush.Color:= clYellow;
c.Pen.Color:= clPurple;
c.Rectangle(90, 100, 130, 140);
c.TextOut(90, 80, 'Rect');
c.Brush.Style:= bsClear;
c.Pen.Color:= clPurple;
c.Rectangle(140, 100, 180, 140);
c.TextOut(130, 80, 'Rect empty');
c.Brush.Color:= clYellow;
c.Pen.Color:= clPurple;
c.FillRect(190, 100, 230, 140);
c.TextOut(190, 80, 'FillRect');
c.Brush.Color:= clYellow;
c.Pen.Color:= clPurple;
c.FrameRect(240, 100, 280, 140);
c.TextOut(240, 80, 'FrmRect');
c.Brush.Style:= bsSolid;
c.Brush.Color:= clYellow;
c.Pen.Color:= clPurple;
c.RoundRect(90+200, 100, 130+200, 140, 10, 10);
c.TextOut(90+200, 80, 'RndRect');
c.Brush.Style:= bsClear;
c.Pen.Color:= clPurple;
c.RoundRect(90+250, 100, 130+250, 140, 10, 10);
c.TextOut(90+250, 80, 'RndRect em');
c.Brush.Color:= clYellow;
c.Brush.Style:= bsSolid;
c.Pen.Color:= clPurple;
c.Ellipse(90, 160, 130, 200);
c.TextOut(90, 140, 'Ellipse');
c.Brush.Style:= bsSolid;
c.Brush.Color:= clYellow;
c.Brush.Style:= bsClear;
c.Pen.Color:= clPurple;
c.Ellipse(140, 160, 180, 200);
c.TextOut(130, 140, 'Ellipse empty');
c.Brush.Style:= bsSolid;
c.Brush.Color:= clYellow;
c.Pen.Color:= clPurple;
c.Polygon([Point(90, 220), Point(130, 230), Point(110, 255)]);
c.TextOut(90, 200, 'Poly');
c.Brush.Style:= bsClear;
c.Pen.Color:= clPurple;
c.Polygon([Point(90+50, 220), Point(130+50, 230), Point(110+50, 255)]);
c.TextOut(90+50, 200, 'Poly empty');
c.Brush.Style:= bsSolid;
C.Pen.Color:= clRed;
C.Polyline([Point(35,80+100),Point(45,80+100),Point(55,80+100),Point(55,90+100),
Point(55,90+100),Point(55,100+100),Point(35,90+100),Point(35,100+100)]);
C.Pen.Color:= clBlue;
C.PolyBezier([Point(35,80+150),Point(45,80+150),Point(55,80+150),Point(55,90+150),
Point(55,90+150),Point(55,100+150),Point(35,90+150),Point(35,100+150)],
false, false);
C.PolyBezier([Point(35,80+150+40),Point(45,80+150+40),Point(55,80+150+40),Point(55,90+150+40),
Point(55,90+150+40),Point(55,100+150+40),Point(35,90+150+40),Point(35,100+150+40)],
true, false);
c.Pen.Color:= clBlue;
for i:= 0 to 6 do
c.Line(250, 20+i*cell, 300, 20+i*cell);
for i:= 0 to 6 do
c.Line(250+i*cell, 20, 250+i*cell, 70);
c.Pen.Color:= clRed;
c.Brush.Color:= clYellow;
i:= 0;
c.Ellipse(250+i*cell, 20+i*cell, 250+(i+1)*cell, 20+(i+1)*cell);
i:= 1;
c.Rectangle(250+i*cell, 20+i*cell, 250+(i+1)*cell, 20+(i+1)*cell);
i:= 2;
c.FillRect(250+i*cell, 20+i*cell, 250+(i+1)*cell, 20+(i+1)*cell);
i:= 3;
c.FrameRect(250+i*cell, 20+i*cell, 250+(i+1)*cell, 20+(i+1)*cell);
c.MoveTo(50, 300);
c.LineTo(50+2*dx+1, 300);
c.MoveTo(50+dx, 300-dx);
c.LineTo(50+dx, 300+dx+1);
c.Pen.Color:= clRed;
c.MoveTo(101, 300);
c.LineTo(110, 300);
c.Pen.Color:= clBlue;
c.MoveTo(110, 301);
c.LineTo(110, 310);
c.Pen.Color:= clRed;
c.MoveTo(109, 310);
c.LineTo(100, 310);
c.Pen.Color:= clBlue;
c.MoveTo(100, 309);
c.LineTo(100, 300);
c.Pixels[100, 300]:= clYellow;
c.Pixels[110, 300]:= clYellow;
c.Pixels[100, 310]:= clYellow;
c.Pixels[110, 310]:= clWhite-2;
if c.Pixels[110, 310]<>clWhite-2 then
caption:= 'not ok: '+IntToStr(c.Pixels[110, 310])
else
caption:= 'ok';
c.Pen.Color:= clRed;
c.MoveTo(102, 302);
c.LineTo(109, 309);
c.Pen.Color:= clBlue;
c.MoveTo(108, 302);
c.LineTo(101, 309);
end;
end.
|
unit DelphiUp.View.Components.Button003;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls,
FMX.Controls.Presentation, FMX.Objects, FMX.Layouts,
DelphiUp.View.Services.Utils, FMX.Effects, FMX.Filter.Effects;
type
TComponentButton003 = class(TForm)
Layout1: TLayout;
Layout2: TLayout;
Layout3: TLayout;
Rectangle1: TRectangle;
Layout4: TLayout;
Image1: TImage;
Label1: TLabel;
SpeedButton1: TSpeedButton;
FillRGBEffect1: TFillRGBEffect;
Rectangle2: TRectangle;
procedure SpeedButton1MouseEnter(Sender: TObject);
procedure SpeedButton1MouseLeave(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
FTitle : String;
FImage : String;
FOnClick : TProc<TObject>;
FBackground : TAlphaColor;
FDestBackground : TAlphaColor;
FAlign : TAlignLayout;
FFontSize : Integer;
FFontColor : TAlphaColor;
FButtonHeight : Integer;
FCountSubMenu : Integer;
public
{ Public declarations }
function Component : TFMXObject;
function Title ( aValue : String ) : TComponentButton003;
function Image ( aValue : String ) : TComponentButton003;
function OnClick ( aValue : TProc<TObject>) : TComponentButton003;
function Background ( aValue : TAlphaColor ) : TComponentButton003;
function DestBackground ( aValue : TAlphaColor ) : TComponentButton003;
function Align ( aValue : TAlignLayout ) : TComponentButton003;
function FontSize ( aValue : Integer ) : TComponentButton003;
function FontColor ( aValue : TAlphaColor ) : TComponentButton003;
function AddSubMenu ( aValue : TFMXObject ) : TComponentButton003;
end;
var
ComponentButton003: TComponentButton003;
implementation
{$R *.fmx}
{ TForm1 }
function TComponentButton003.AddSubMenu(
aValue: TFMXObject): TComponentButton003;
begin
Result := Self;
Layout3.AddObject(aValue);
Inc(FCountSubMenu);
TServiceUtils.ResourceImage('ico_down', Image1);
end;
function TComponentButton003.Align(aValue: TAlignLayout): TComponentButton003;
begin
Result := Self;
FAlign := aValue;
Layout1.Align := aValue;
end;
function TComponentButton003.Background(
aValue: TAlphaColor): TComponentButton003;
begin
Result := Self;
FBackground := aValue;
Rectangle1.Fill.Color := aValue;
end;
function TComponentButton003.Component: TFMXObject;
begin
Result := Layout1;
Layout1.Height := FButtonHeight;
Image1.Visible := False;
Image1.Visible := not (FCountSubMenu = 0);
Layout3.Visible := False;
end;
function TComponentButton003.DestBackground(
aValue: TAlphaColor): TComponentButton003;
begin
Result := Self;
FDestBackground := aValue;
Rectangle2.Fill.Color := aValue;
end;
function TComponentButton003.FontColor(
aValue: TAlphaColor): TComponentButton003;
begin
Result := Self;
FFontColor := aValue;
Label1.FontColor := aValue;
FillRGBEffect1.Color := aValue;
end;
function TComponentButton003.FontSize(aValue: Integer): TComponentButton003;
begin
Result := Self;
FFontSize := aValue;
Label1.TextSettings.Font.Size := aValue;
end;
procedure TComponentButton003.FormCreate(Sender: TObject);
begin
FButtonHeight := 50;
FCountSubMenu := 0;
end;
function TComponentButton003.Image(aValue: String): TComponentButton003;
begin
Result := Self;
FImage := aValue;
TServiceUtils.ResourceImage(aValue, Image1);
end;
function TComponentButton003.OnClick(
aValue: TProc<TObject>): TComponentButton003;
begin
Result := Self;
FOnClick := aValue;
end;
procedure TComponentButton003.SpeedButton1Click(Sender: TObject);
begin
if Assigned(FOnClick) then
FOnClick(Sender);
Layout1.Height := FButtonHeight;
if FCountSubMenu > 0 then
begin
if not Layout3.Visible then
Layout1.Height := FButtonHeight + (FCountSubMenu * FButtonHeight);
Layout3.Visible := not Layout3.Visible;
TServiceUtils.ResourceImage('ico_down', Image1);
if Layout3.Visible then
TServiceUtils.ResourceImage('ico_up', Image1);
end;
end;
procedure TComponentButton003.SpeedButton1MouseEnter(Sender: TObject);
begin
Rectangle1.Fill.Color := FDestBackground;
Image1.Visible := True;
end;
procedure TComponentButton003.SpeedButton1MouseLeave(Sender: TObject);
begin
Rectangle1.Fill.Color := FBackground;
if FCountSubMenu <= 0 then
Image1.Visible := False;
end;
function TComponentButton003.Title(aValue: String): TComponentButton003;
begin
Result := Self;
FTitle := aValue;
Label1.Text := aValue;
end;
end.
|
unit Frame.DataTypes;
interface
uses
System.SysUtils,
System.Types,
System.UITypes,
System.Classes,
System.Variants,
FMX.Types,
FMX.Graphics,
FMX.Controls,
FMX.Forms,
FMX.Dialogs,
FMX.StdCtrls,
FMX.Controls.Presentation;
type
TFrameDataTypes = class(TFrame)
ButtonObject: TButton;
ButtonMemory: TButton;
ButtonTBytes: TButton;
ButtonTStrings: TButton;
ButtonFloat: TButton;
ButtonInteger: TButton;
ButtonString: TButton;
procedure ButtonStringClick(Sender: TObject);
procedure ButtonIntegerClick(Sender: TObject);
procedure ButtonFloatClick(Sender: TObject);
procedure ButtonTStringsClick(Sender: TObject);
procedure ButtonTBytesClick(Sender: TObject);
procedure ButtonMemoryClick(Sender: TObject);
procedure ButtonObjectClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
implementation
{$R *.fmx}
uses
System.TypInfo,
Grijjy.SysUtils,
Grijjy.CloudLogging;
procedure TFrameDataTypes.ButtonFloatClick(Sender: TObject);
begin
GrijjyLog.Send('Float value', Pi, TgoLogLevel.Warning);
end;
procedure TFrameDataTypes.ButtonIntegerClick(Sender: TObject);
begin
GrijjyLog.Send('Integer value', 42, TgoLogLevel.Warning);
end;
procedure TFrameDataTypes.ButtonMemoryClick(Sender: TObject);
var
Bytes: TBytes;
I: Integer;
begin
SetLength(Bytes, 997);
for I := 0 to Length(Bytes) - 1 do
Bytes[I] := Random(256);
Bytes[10] := 0;
GrijjyLog.Send('Memory value', @Bytes[0], Length(Bytes), TgoLogLevel.Warning);
end;
procedure TFrameDataTypes.ButtonObjectClick(Sender: TObject);
begin
GrijjyLog.Send('Object value', Self, mvPublic, 4, TgoLogLevel.Warning);
end;
procedure TFrameDataTypes.ButtonStringClick(Sender: TObject);
begin
GrijjyLog.Send('String value', 'Foo', TgoLogLevel.Warning);
end;
procedure TFrameDataTypes.ButtonTBytesClick(Sender: TObject);
var
Bytes: TBytes;
begin
Bytes := TEncoding.UTF8.GetBytes
('The Quick Brown Fox Jumps Over The Lazy Dog');
GrijjyLog.Send('TBytes value', Bytes, TgoLogLevel.Warning);
end;
procedure TFrameDataTypes.ButtonTStringsClick(Sender: TObject);
var
S: TStringList;
begin
S := TStringList.Create;
try
S.Add('Foo');
S.Add('With Spaces');
S.Add('With, Commas');
S.Add('With "Quotes"');
S.Add('With ''Quotes''');
S.Add('Width , "every", ''thing''');
GrijjyLog.Send('TStrings value', S, TgoLogLevel.Warning);
finally
S.Free;
end;
end;
end.
|
unit NativeEdObjects;
interface
uses
XMLFile, EditableObjects;
type
TNativeMetaEditableObject =
class(TMetaEditableObject)
public
function Instantiate( aName, aValue : string; const data ) : TEditableObject; override;
procedure Clone( aMetaEditableObject : TMetaEditableObject ); override;
private
fInstancesEditor : TObjectEditor;
fInstancesOptions : integer;
public
property InstancesEditor : TObjectEditor read fInstancesEditor write fInstancesEditor;
property InstancesOptions : integer read fInstancesOptions write fInstancesOptions;
end;
TNativeMetaObjectPool =
class(TMetaObjectPool)
public
procedure Init( const data ); override;
procedure Save( filename : string );
private
procedure ReadMetaInstances( filename : string );
procedure SaveMetaInstance( where : TXMLNode; Instance : TNativeMetaEditableObject );
procedure SaveProperty( where : TXMLNode; prop : TNativeMetaEditableObject );
end;
var
TheMetaObjectPool : TNativeMetaObjectPool;
procedure CreateMetaObjectPool;
procedure InitMetaObjectPool( defFile : string );
procedure DestroyMetaObjectPool;
implementation
uses
classes, sysutils, stringUtils;
// TNativeMetaEditableObject
function TNativeMetaEditableObject.Instantiate( aName, aValue : string; const data ) : TEditableObject;
var
i : integer;
newProp : TEditableObject;
begin
result := TEditableObject.Create;
result.ObjectEditor := fInstancesEditor;
result.MetaClass := self;
result.Name := aName;
result.Value := aValue;
result.Options := fInstancesOptions;
for i := 0 to pred(fProperties.Count) do
with TMetaEditableObject(fProperties[i]) do
begin
newProp := TMetaEditableObject(fProperties[i]).Instantiate( TEditableObject(fProperties[i]).Name, TEditableObject(fProperties[i]).Value, data );
result.Properties.Insert( newProp );
end;
end;
procedure TNativeMetaEditableObject.Clone( aMetaEditableObject : TMetaEditableObject );
var
NativeMetaObject : TNativeMetaEditableObject;
prop : TNativeMetaEditableObject;
i : integer;
begin
NativeMetaObject := TNativeMetaEditableObject(aMetaEditableObject);
NativeMetaObject.ObjectEditor := ObjectEditor;
NativeMetaObject.InstancesEditor := InstancesEditor;
NativeMetaObject.Options := NativeMetaObject.Options or Options;
NativeMetaObject.fInstancesOptions := fInstancesOptions;
NativeMetaObject.MetaClass := MetaClass;
for i := 0 to pred(fProperties.Count) do
begin
prop := TNativeMetaEditableObject.Create;
prop.Name := TNativeMetaEditableObject(fProperties[i]).Name;
prop.Value := TNativeMetaEditableObject(fProperties[i]).Value;
TNativeMetaEditableObject(fProperties[i]).Clone( prop );
NativeMetaObject.Properties.Insert( prop );
end;
end;
// TNativeMetaObjectPool
procedure TNativeMetaObjectPool.Init( const data );
var
filename : string absolute data;
begin
ReadMetaInstances( filename );
end;
procedure TNativeMetaObjectPool.Save( filename : string );
var
XMLFile : TXMLFile;
procedure _Save( Instance : TNativeMetaEditableObject );
var
i : integer;
node : TXMLNode;
begin
node := XMLFile.CreateNode( '/root/Metaclasses', 'Metaclass' );
try
SaveMetaInstance( node, Instance );
finally
node.Free;
end;
for i := 0 to pred(Instance.Children.Count) do
_Save( TNativeMetaEditableObject(Instance.Children[i]) );
end;
var
i : integer;
begin
XMLFile := TXMLFile.Create;
try
XMLFile.CreateNode( '', 'Metaclasses' );
for i := 0 to pred(fMetaObjects.Count) do
_Save( TNativeMetaEditableObject(fMetaObjects[i]) );
XMLFile.Save( filename );
finally
XMLFile.Free;
end;
end;
procedure TNativeMetaObjectPool.ReadMetaInstances( filename : string );
function createMetaObject( ancestor : TNativeMetaEditableObject; cname : string ): TNativeMetaEditableObject;
var
i : integer;
begin
result := TNativeMetaEditableObject.Create;
result.Name := cName;
result.ObjectEditor := getEditor( cname );
if ancestor <> nil
then
begin
if ancestor.getChildren( cname ) = nil
then
begin
result.fInstancesEditor := ancestor.fInstancesEditor;
ancestor.Children.Insert( result );
result.Parent := ancestor;
for i := 0 to pred(ancestor.Properties.Count) do
result.Properties.Insert( ancestor.Properties[i] );
end;
end
else
begin
if get( cname ) = nil
then fMetaObjects.Insert( result );
end;
end;
procedure ReadProperty( obj : TNativeMetaEditableObject; node : TXMLNode );
var
prop : TNativeMetaEditableObject;
prop1 : TNativeMetaEditableObject;
MetaClass : TNativeMetaEditableObject;
i : integer;
newProp : boolean;
propName : string;
cName : string;
aux : integer;
proplist : TList;
propNode : TXMLNode;
begin
try
propName := node.ReadString( 'name', '' );
if propName <> ''
then
begin
prop := TNativeMetaEditableObject(obj.getProperty( propName ));
newProp := prop = nil;
if newProp
then
begin
prop := TNativeMetaEditableObject.Create;
prop.Name := propName;
end;
cName := node.ReadString( 'class', '' );
if cName <> ''
then
begin
if newProp
then
begin
MetaClass := TNativeMetaEditableObject(get( cName ));
if MetaClass <> nil
then
begin
MetaClass.Clone( prop );
prop.MetaClass := MetaClass;
end;
end;
end;
prop.Value := node.ValueAsString;
aux := node.ReadInteger( 'options', 0 );
if aux <> 0
then prop.Options := aux;
aux := node.ReadInteger( 'i_options', 0 );
if aux <> 0
then prop.InstancesOptions := aux;
proplist := TList.Create;
try
node.queryChilds( 'property', proplist );
for i := 0 to pred(proplist.Count) do
begin
propNode := TXMLNode(proplist[i]);
prop1 := TNativeMetaEditableObject(prop.getProperty( propNode.ReadString( 'name', '' )));
if prop1 = nil
then
begin
prop1 := TNativeMetaEditableObject.Create;
prop1.Name := propNode.ReadString( 'name', '' );
prop1.Value := propNode.ValueAsString;
prop.Properties.Insert( prop1 );
end
else
begin
prop1.Value := propNode.ValueAsString;
end;
propNode.Free;
end;
finally
proplist.Free;
end;
if newProp
then obj.Properties.Insert( prop );
end
finally
node.Free;
end;
end;
var
XMLFile : TXMLFile;
currClass : TXMLNode;
cName : string;
i, j : integer;
anc : TNativeMetaEditableObject;
obj : TNativeMetaEditableObject;
ancestor : string;
classlist : TList;
propList : TList;
begin
XMLFile := TXMLFile.Create;
classlist := TList.Create;
propList := TList.Create;
try
XMLFile.Load( filename );
XMLFile.queryNodes( '/root/Metaclasses', 'Metaclass', classlist );
for i := 0 to pred(classlist.Count) do
begin
currClass := TXMLNode(classlist[i]);
cName := currClass.ReadString( 'name', '' );
if cName <> ''
then
begin
ancestor := currClass.ReadString( 'ancestor', '' );
anc := TNativeMetaEditableObject(get( ancestor ));
obj := createMetaObject( anc, cName );
obj.fInstancesEditor := getEditor( currClass.ReadString( 'i_editor', '' ));
obj.Value := currClass.ValueAsString;
obj.InstancesOptions := currClass.ReadInteger( 'i_options', 0 );
obj.Options := currClass.ReadInteger( 'options', 0 );
obj.ObjectEditor := getEditor( currClass.ReadString( 'editor', '' ));
propList.Clear;
currClass.queryChilds( 'property', propList );
for j := 0 to pred(propList.Count) do
ReadProperty( obj, TXMLNode(propList[j]) );
if (obj.InstancesEditor = nil) and (anc <> nil)
then obj.InstancesEditor := anc.InstancesEditor;
end;
currClass.Free;
end;
finally
XMLFile.Free;
classlist.Free;
propList.Free;
end;
end;
procedure TNativeMetaObjectPool.SaveMetaInstance( where : TXMLNode; Instance : TNativeMetaEditableObject );
var
i : integer;
propNode : TXMLNode;
begin
with where do
begin
if Instance.Parent <> nil
then WriteString( 'ancestor', Instance.Parent.getFullName );
WriteString( 'name', Instance.Name );
if Instance.InstancesEditor <> nil
then WriteString( 'i_editor', Instance.InstancesEditor.Name );
setValueAsString( Instance.Value );
WriteInteger( 'i_options', Instance.InstancesOptions );
WriteInteger( 'options', Instance.Options );
if Instance.InstancesEditor <> nil
then WriteString( 'i_editor', Instance.InstancesEditor.Name );
if Instance.ObjectEditor <> nil
then WriteString( 'editor', Instance.ObjectEditor.Name );
for i := 0 to pred(Instance.Properties.Count) do
begin
propNode := where.CreateChild( 'property' );
SaveProperty( propNode, TNativeMetaEditableObject(Instance.Properties[i]) );
propNode.Free;
end;
end;
end;
procedure TNativeMetaObjectPool.SaveProperty( where : TXMLNode; prop : TNativeMetaEditableObject );
var
i : integer;
node : TXMLNode;
begin
where.WriteString( 'name', prop.Name );
if prop.MetaClass <> nil
then where.WriteString( 'class', prop.MetaClass.getFullName );
where.setValueAsString( prop.Value );
where.WriteInteger( 'options', prop.Options );
where.WriteInteger( 'i_options', prop.InstancesOptions );
for i := 0 to pred( prop.Properties.Count) do
begin
node := where.CreateChild( 'property' );
try
node.WriteString( 'name', TNativeMetaEditableObject(prop.Properties[i]).Name );
node.WriteString( 'value', TNativeMetaEditableObject(prop.Properties[i]).Value );
finally
node.Free;
end;
end;
end;
procedure CreateMetaObjectPool;
begin
TheMetaObjectPool := TNativeMetaObjectPool.Create;
end;
procedure InitMetaObjectPool( defFile : string );
begin
TheMetaObjectPool.Init( defFile );
end;
procedure DestroyMetaObjectPool;
begin
TheMetaObjectPool.Free;
end;
end.
|
{
DBAExplorer - Oracle Admin Management Tool
Copyright (C) 2008 Alpaslan KILICKAYA
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
}
unit frmProcedureDetail;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OraProcSource, Menus, cxLookAndFeelPainters, StdCtrls,
cxButtons, ExtCtrls, cxGraphics, cxTextEdit, cxMaskEdit, cxDropDownEdit,
cxControls, cxContainer, cxEdit, cxGroupBox, GenelDM, cxLookupEdit,
cxDBLookupEdit, cxDBLookupComboBox, OraStorage;
type
TProcedureDetailFrm = class(TForm)
cxGroupBox1: TcxGroupBox;
Label1: TLabel;
cbObjectType: TcxComboBox;
Label2: TLabel;
edtObjectName: TcxTextEdit;
Label3: TLabel;
lcViewSchema: TcxLookupComboBox;
cxGroupBox2: TcxGroupBox;
btnOK: TcxButton;
btnCancel: TcxButton;
procedure btnOKClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
function Init(ProcSource: TProcSource): TProcSource;
end;
var
ProcedureDetailFrm: TProcedureDetailFrm;
implementation
{$R *.dfm}
uses Util, VisualOptions;
function TProcedureDetailFrm.Init(ProcSource: TProcSource): TProcSource;
var
FProcSource: TProcSource;
begin
ProcedureDetailFrm := TProcedureDetailFrm.Create(Application);
Self := ProcedureDetailFrm;
DMGenel.ChangeLanguage(self);
ChangeVisualGUI(self);
dmGenel.ReLoad(ProcSource.OraSession);
lcViewSchema.Text := ProcSource.OWNER;
if ProcSource.SOURCE_TYPE = stProcedure then
cbObjectType.Text := 'Procedure';
if ProcSource.SOURCE_TYPE = stPackage then
cbObjectType.Text := 'Package';
if ProcSource.SOURCE_TYPE = stFunction then
cbObjectType.Text := 'Function';
if ProcSource.SOURCE_TYPE = stType then
cbObjectType.Text := 'Type';
ShowModal;
if ModalResult = mrOK then
begin
FProcSource := TProcSource.Create;
FProcSource.OraSession := ProcSource.OraSession;
FProcSource.OWNER := lcViewSchema.Text;
FProcSource.SOURCE_NAME := edtObjectName.Text;
if cbObjectType.Text = 'Procedure' then
FProcSource.SOURCE_TYPE := stProcedure;
if cbObjectType.Text = 'Package' then
FProcSource.SOURCE_TYPE := stPackage;
if cbObjectType.Text = 'Function' then
FProcSource.SOURCE_TYPE := stFunction;
if cbObjectType.Text = 'Type' then
FProcSource.SOURCE_TYPE := stType;
result := FProcSource;
end else
begin
result := nil;
end;
Free;
end;
procedure TProcedureDetailFrm.btnOKClick(Sender: TObject);
begin
if edtObjectName.Text = '' then
begin
MessageDlg('Object Name must be specified', mtWarning, [mbOk], 0);
abort;
end;
ModalResult := mrOK;
end;
end.
|
unit frame.pianoroll;
interface
uses
Winapi.Windows, Winapi.Messages,
System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls,
Vcl.GraphUtil;
type
TPianoRollMode = (Select, AdjustSize);
TNoteCountEvent = procedure(sender: TObject; var count: integer) of object;
TGetNoteEvent = procedure(sender: TObject; index: integer;
var osc, note, start, length: integer) of object;
TNoteUpdateEvent = procedure(sender: TObject; index, note, start: integer) of object;
TNoteRightClickEvent = procedure(sender: TObject; note: integer) of object;
TPianoRollFrame = class(TFrame)
PianoRollPaint: TPaintBox;
procedure OnPianoRollPaint(Sender: TObject);
procedure OnMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure OnMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
procedure OnMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
m_noteCountEvent: TNoteCountEvent;
m_getNoteEvent: TGetNoteEvent;
m_noteUpdateEvent: TNoteUpdateEvent;
m_noteRightClickEvent: TNoteRightClickEvent;
m_mode: TPianoRollMode;
m_move, m_snapToGrid: boolean;
m_selectedNote: integer;
m_numSteps: integer;
m_cursor: integer;
function GetNoteRect(note, start, length: integer): TRect;
function DoCountEvent: integer;
procedure DoGetNoteEvent(index: integer; var osc, note, start, length: integer);
procedure DoNoteUpdateEvent(index, note, start: integer);
procedure DoRightClick(note: integer);
procedure SetCursor(const Value: integer);
public
{ Public declarations }
constructor Create(anOwner: TComponent); override;
procedure Refresh;
property Cursor: integer read m_cursor write SetCursor;
property Mode: TPianoRollMode read m_mode write m_mode;
property Selected: integer read m_selectedNote;
property OnNoteCount: TNoteCountEvent
read m_noteCountEvent write m_noteCountEvent;
property OnGetNote: TGetNoteEvent
read m_getNoteEvent write m_getNoteEvent;
property OnNoteUpdate: TNoteUpdateEvent
read m_noteUpdateEvent write m_noteUpdateEvent;
property OnNoteRightClick: TNoteRightClickEvent
read m_noteRightClickEvent write m_noteRightClickEvent;
end;
implementation
{$R *.dfm}
uses helper.utilities;
const
CellWidth = 24;
CellHeight = 12;
constructor TPianoRollFrame.Create(anOwner: TComponent);
begin
inherited;
m_selectedNote := -1;
m_cursor := -1;
m_numSteps := 32;
m_move := false;
m_snapToGrid := false;
m_noteCountEvent := nil;
m_getNoteEvent := nil;
m_noteUpdateEvent := nil;
m_noteRightClickEvent := nil;
m_mode := TPianoRollMode.Select;
end;
function TPianoRollFrame.DoCountEvent: integer;
var
count: integer;
begin
result := 0;
if Assigned(m_noteCountEvent) then
begin
m_noteCountEvent(self, count);
result := count;
end;
end;
procedure TPianoRollFrame.DoGetNoteEvent(index: integer;
var osc, note, start, length: integer);
begin
if Assigned(m_getNoteEvent) then
m_getNoteEvent(self, index, osc, note, start, length);
end;
procedure TPianoRollFrame.DoNoteUpdateEvent(index, note, start: integer);
begin
if Assigned(m_noteUpdateEvent) then
m_noteUpdateEvent(self, index, note, start);
end;
procedure TPianoRollFrame.DoRightClick(note: integer);
begin
if Assigned(m_noteRightClickEvent) then
m_noteRightClickEvent(self, note);
end;
function TPianoRollFrame.GetNoteRect(note, start, length: integer): TRect;
var
rect: TRect;
begin
SetRect(rect,
start,
(35 - note - 1) * CellHeight,
start + length,
(35 - note - 1) * CellHeight + CellHeight);
result := rect;
end;
procedure TPianoRollFrame.OnMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
i, count, osc, note, start, length: integer;
point: TPoint;
rect: TRect;
begin
if Button = mbLeft then
begin
count := DoCountEvent;
m_selectedNote := -1;
m_move := false;
for i := 0 to count - 1 do
begin
DoGetNoteEvent(i, osc, note, start, length);
rect := GetNoteRect(note, start, length);
point.X := x;
point.Y := y;
if rect.Contains(point) then
begin
m_selectedNote := i;
m_move := true;
break;
end;
end;
PianoRollPaint.Refresh;
end;
if Button = mbRight then
begin
count := DoCountEvent;
note := -1;
for i := 0 to count - 1 do
begin
DoGetNoteEvent(i, osc, note, start, length);
rect := GetNoteRect(note, start, length);
point.X := x;
point.Y := y;
if rect.Contains(point) then
begin
DoRightClick(i);
break;
end;
end;
end;
end;
procedure TPianoRollFrame.OnMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if m_move then
begin
x := THelperUtilities.ClampToGrid(x, 0, CellWidth * m_numSteps, CellWidth);
DoNoteUpdateEvent(m_selectedNote, 34 - y div CellHeight, x);
PianoRollPaint.Refresh;
end;
end;
procedure TPianoRollFrame.OnMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
m_move := false;
end;
procedure TPianoRollFrame.OnPianoRollPaint(Sender: TObject);
var
i, x, y, h, osc, note, start, length: integer;
dark, light, background: TColor;
noteCount: integer;
rect: TRect;
begin
light := clLtGray;
dark := clDkGray;
background := clWhite;
h := 35 * CellHeight;
with PianoRollPaint.Canvas do
begin
SetRect(rect, 0, 0, PianoRollPaint.Width, PianoRollPaint.Height);
Brush.Color := background;
FillRect(rect);
Pen.Width := 0;
for x := 0 to m_numSteps do
begin
if x mod 4 = 0 then
Pen.Color := dark
else
Pen.Color := light;
MoveTo(x * CellWidth, 0);
LineTo(x * CellWidth, h);
end;
Pen.Color := clLtGray;
for y := 0 to 35 do
begin
if y mod 7 = 0 then
Pen.Color := dark
else
Pen.Color := light;
MoveTo(0, y * CellHeight);
LineTo(m_numSteps * CellWidth, y * CellHeight);
end;
noteCount := DoCountEvent;
Pen.Color := clBlack;
for i := 0 to noteCount - 1 do
begin
DoGetNoteEvent(i, osc, note, start, length);
rect := GetNoteRect(note, start, length);
if i = m_selectedNote then
Brush.Color := clRed
else
case osc of
0: Brush.Color := clOlive;
1: Brush.Color := clSkyBlue;
end;
Rectangle(rect);
end;
if m_cursor <> -1 then
begin
{*if m_cursor > 0 then
begin
SetRect(rect, CellWidth * m_cursor - CellWidth, 0,
CellWidth * m_cursor, 35 * CellHeight);
GradientFillCanvas(PianoRollPaint.Canvas, clNone, clRed, rect,
TGradientDirection.gdHorizontal);
end
else
begin
Pen.Color := clRed;
MoveTo(CellWidth * m_cursor, 0);
LineTo(CellWidth * m_cursor, 35 * CellHeight);
end;*}
Pen.Color := clRed;
Pen.Width := 3;
MoveTo(CellWidth * m_cursor, 0);
LineTo(CellWidth * m_cursor, 35 * CellHeight);
end;
end;
end;
procedure TPianoRollFrame.Refresh;
begin
PianoRollPaint.Refresh;
end;
procedure TPianoRollFrame.SetCursor(const Value: integer);
begin
m_cursor := value;
PianoRollPaint.Refresh;
end;
end.
|
{***********************************************************************************************************************
*
* TERRA Game Engine
* ==========================================
*
* Copyright (C) 2003, 2014 by SÚrgio Flores (relfos@gmail.com)
*
***********************************************************************************************************************
*
* 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.
*
**********************************************************************************************************************
* TERRA_Resource
* Implements the generic Resource class
***********************************************************************************************************************
}
Unit TERRA_Resource;
{$I terra.inc}
Interface
Uses TERRA_String, TERRA_Collections, TERRA_Hashmap, TERRA_Stream;
Type
ResourceStatus = (
rsUnloaded = 0,
rsBusy = 1,
rsInvalid = 2,
rsReady = 3
);
ResourceType = (
rtLoaded = 0,
rtStreamed = 1,
rtDynamic = 2
);
ResourceClass = Class Of Resource;
Resource = Class(HashMapObject)
Private
_Status:ResourceStatus;
_Kind:ResourceType;
Protected
_Time:Cardinal;
_Location:TERRAString;
_Size:Integer;
Procedure CopyValue(Other:CollectionObject); Override;
Function Sort(Other:CollectionObject):Integer; Override;
Procedure SetStatus(const Value:ResourceStatus);
Function Build():Boolean; Virtual;
Public
Priority:Integer;
Constructor Create(Kind:ResourceType; Location:TERRAString);
Procedure Release; Override;
Procedure Touch;
Function IsReady:Boolean;
Class Function GetManager:Pointer; Virtual;
Function Load(MyStream:Stream):Boolean; Virtual;Abstract;
Function Unload:Boolean; Virtual;
Function Update:Boolean; Virtual;
Procedure Rebuild();
Function ToString():TERRAString; Override;
Procedure Prefetch;
Function ShouldUnload():Boolean;
Property Name:TERRAString Read _Key;
Property Location:TERRAString Read _Location;
Property Time:Cardinal Read _Time Write _Time;
Property Status:ResourceStatus Read _Status Write SetStatus;
Property Kind:ResourceType Read _Kind;
Property Size:Integer Read _Size;
End;
Implementation
Uses TERRA_Error, TERRA_Log, TERRA_OS, TERRA_Utils, TERRA_ResourceManager, TERRA_FileStream, TERRA_GraphicsManager,
TERRA_FileUtils, TERRA_Application, TERRA_FileManager;
Procedure Resource.CopyValue(Other: CollectionObject);
Begin
RaiseError('Not implemented!');
End;
Constructor Resource.Create(Kind:ResourceType; Location:TERRAString);
Var
I:Integer;
Begin
Self._Kind := Kind;
If Kind = rtDynamic Then
Begin
Self._Key := Location;
Self._Location := '';
End Else
Begin
Self._Key := GetFileName(Location,True);
Self._Location := Location;
End;
Self._Size := 0;
Self.SetStatus(rsUnloaded);
Self.Priority := 50;
End;
Procedure Resource.Release;
Begin
Log(logDebug, 'Resource', 'Destroying resource '+Self.Name);
{$IFNDEF ANDROID}
Self.Unload();
{$ENDIF}
End;
Class Function Resource.GetManager: Pointer;
Begin
Result := Nil;
End;
Function Resource.IsReady:Boolean;
Var
Manager:ResourceManager;
Begin
// Log(logDebug, 'Resource', 'Calling isReady()...');
If (Self = Nil) Then
Begin
Result := False;
Exit;
End;
If (Status = rsReady) Then
Begin
Self.Touch();
Result := True;
Exit;
End;
Result := False;
If (Status <> rsUnloaded) Then
Exit;
(*If (Not _Prefetching) And (Application.Instance.FrameTime>500) Then
Begin
Result := False;
Exit;
End;*)
If Self.Name = '' Then
IntToString(2);
Log(logDebug, 'Resource', 'Obtaining manager for '+Self.Name);
Manager := Self.GetManager;
If (Manager = Nil) Then
Begin
Log(logDebug, 'Resource', 'Failed to obtain a manager...');
Exit;
End;
If (Self.Location<>'') Then
Begin
Self.SetStatus(rsBusy);
Log(logDebug, 'Resource', 'Loading the resource...');
Manager.ReloadResource(Self, Manager.UseThreads);
Result := (Status = rsReady);
End Else
Begin
Log(logDebug, 'Resource', 'Updating the resource...' + Self.ClassName);
Self.Rebuild();
Result := True;
End;
End;
Procedure Resource.Prefetch;
Begin
If (Self.Status<>rsUnloaded) Then
Exit;
Log(logDebug, 'Resource', 'Prefetching '+ Self.Name);
If Self.IsReady() Then
Exit;
If _Prefetching Then
Begin
Log(logDebug, 'Resource', 'Prefetch overflow!');
Exit;
End;
Log(logDebug, 'Resource', 'Prefetching '+Self.Name);
_Prefetching := True;
While (Not Self.IsReady) Do
Begin
Application.Instance.RefreshComponents();
If (Self.Status = rsInvalid) Then
Break;
End;
_Prefetching := False;
If (Self.Status = rsInvalid) Then
Log(logError, 'Resource', 'Error prefetching resource')
Else
Log(logDebug, 'Resource', 'Prefetching for '+Self.Name+' is done!');
End;
Function Resource.Sort(Other: CollectionObject): Integer;
Begin
Result := GetStringSort(Self.Name, Resource(Other).Name);
End;
Function Resource.ToString:TERRAString;
Begin
Result := Self.Name;
End;
Function Resource.Unload:Boolean;
Begin
SetStatus(rsUnloaded);
Result := True;
End;
Function Resource.Update:Boolean;
Begin
Result := True;
End;
Function Resource.ShouldUnload: Boolean;
Begin
Result := (Application.GetTime() - Self.Time > ResourceDiscardTime);
End;
Procedure Resource.SetStatus(const Value:ResourceStatus);
Var
Manager:ResourceManager;
Begin
{If Value<>rsUnloaded Then
StringToInt(Self._Key);}
If (_Location = '') Then
Begin
_Status := Value;
Exit;
End;
Manager := Self.GetManager;
If (Manager = Nil) Then
Begin
Log(logDebug, 'Resource', 'Failed to obtain a manager...');
Exit;
End;
Manager.Lock();
_Status := Value;
Manager.Unlock();
End;
Function Resource.Build: Boolean;
Begin
Result := False;
End;
Procedure Resource.Rebuild;
Begin
Self.SetStatus(rsBusy);
If Self.Build() Then
Begin
Self.Update();
Self.SetStatus(rsReady);
End Else
Self.SetStatus(rsUnloaded);
End;
Procedure Resource.Touch;
Begin
_Time := Application.GetTime();
End;
End.
|
unit afTextNormalizer;
{ Убирает разрядку пробелами из слов }
// $Id: afTextNormalizer.pas,v 1.4 2014/04/29 14:06:19 lulin Exp $
// $Log: afTextNormalizer.pas,v $
// Revision 1.4 2014/04/29 14:06:19 lulin
// - вычищаем ненужные зависимости.
//
// Revision 1.3 2014/04/11 15:30:52 lulin
// - переходим от интерфейсов к объектам.
//
// Revision 1.2 2013/04/16 09:30:55 fireton
// - не собиралось
//
// Revision 1.1 2013/04/16 08:09:55 narry
// Автоматические форматировщики
//
interface
uses
dd_lcTextFormatter2, k2Interfaces, evdLeafParaFilter;
type
TafTextNormalizer = class(Tdd_lcBaseFormatter)
private
procedure NormalizeText(aLeaf: Tl3Tag);
protected
function EnableWrite(aPara: Tl3Variant): Tdd_lcTextReaction; override;
end;
type
TlukEmptyParaEliminator = class(TevdLeafParaFilter)
protected
function NeedWritePara(aLeaf: Tl3Variant): Boolean; override;
end;
implementation
uses
l3String, SysUtils, k2Tags, l3RegEx, l3Chars;
function TafTextNormalizer.EnableWrite(aPara: Tl3Tag): Tdd_lcTextReaction;
begin
Result:= lcWrite;
NormalizeText(aPara);
end;
procedure TafTextNormalizer.NormalizeText(aLeaf: Tl3Tag);
var
i: Integer;
l_Text, l_AllText: String;
l_Pos: Tl3MatchPosition;
const
cPattern = '>\c\s(\c\s)+\c';
begin
l_Text:= '';
RegSearcher.SearchPattern:= cPattern;
if RegSearcher.SearchInString(aLeaf.PCharLenA[k2_tiText], l_Pos) then
begin
l_Text:= Copy(aLeaf.StrA[k2_tiText], Succ(l_Pos.StartPos), l_Pos.Length);
if Length(l_Text) > 6 then
begin
l_AllText:= aLeaf.StrA[k2_tiText];
Delete(l_AllText, Succ(l_Pos.StartPos), l_Pos.Length);
i:= 2;
while i < Length(l_Text) do
begin
if l_Text[i] in [cc_HardSpace, cc_SoftSpace] then
Delete(l_Text, i, 1);
Inc(i);
end; // while
Insert(l_Text, l_AllText, l_Pos.StartPos+1);
aLeaf.StrW[k2_tiText, nil]:= l_AllText;
end; // Length(l_Text) > 6
end; // RegSearcher.SearchInString
end;
function TlukEmptyParaEliminator.NeedWritePara(aLeaf: Tl3Tag): Boolean;
begin
Result:= aLeaf.Attr[k2_tiText].IsValid and (aLeaf.Attr[k2_tiText].AsPCharLen.SLen > 0)
end;
end.
|
unit FFSRPTSTable;
interface
uses
Classes, DB, DBISAMTb, SysUtils, DBISAMTableAU, DataBuf;
type
TFFSRPTSRecord = record
PCNumber: String[20];
PInstallDate: String[10];
PNumberOfRuns: Integer;
PRunNumberNow: Integer;
End;
TFFSRPTSBuffer = class(TDataBuf)
protected
function PtrIndex(Index:integer):Pointer;override;
public
Data: TFFSRPTSRecord;
function FieldNameToIndex(s:string):integer;override;
function FieldType(index:integer):TFieldType;override;
end;
TEIFFSRPTS = (FFSRPTSPrimaryKey);
TFFSRPTSTable = class( TDBISAMTableAU )
private
FDFCNumber: TStringField;
FDFInstallDate: TStringField;
FDFNumberOfRuns: TIntegerField;
FDFRunNumberNow: TIntegerField;
procedure SetPCNumber(const Value: String);
function GetPCNumber:String;
procedure SetPInstallDate(const Value: String);
function GetPInstallDate:String;
procedure SetPNumberOfRuns(const Value: Integer);
function GetPNumberOfRuns:Integer;
procedure SetPRunNumberNow(const Value: Integer);
function GetPRunNumberNow:Integer;
function GenerateNewFieldName( AOwner: TComponent; const DatasetName: string; const FieldName: string ): string;
procedure SetEnumIndex(Value: TEIFFSRPTS);
function GetEnumIndex: TEIFFSRPTS;
protected
function CreateField( const FieldName : string ): TField;
procedure CreateFields; reintroduce;
procedure SetActive(Value: Boolean); override;
procedure LoadFieldDefs(AStringList:TStringList);override;
procedure LoadIndexDefs(AStringList:TStringList);override;
public
function GetDataBuffer:TFFSRPTSRecord;
procedure StoreDataBuffer(ABuffer:TFFSRPTSRecord);
property DFCNumber: TStringField read FDFCNumber;
property DFInstallDate: TStringField read FDFInstallDate;
property DFNumberOfRuns: TIntegerField read FDFNumberOfRuns;
property DFRunNumberNow: TIntegerField read FDFRunNumberNow;
property PCNumber: String read GetPCNumber write SetPCNumber;
property PInstallDate: String read GetPInstallDate write SetPInstallDate;
property PNumberOfRuns: Integer read GetPNumberOfRuns write SetPNumberOfRuns;
property PRunNumberNow: Integer read GetPRunNumberNow write SetPRunNumberNow;
published
property Active write SetActive;
property EnumIndex: TEIFFSRPTS read GetEnumIndex write SetEnumIndex;
end; { TFFSRPTSTable }
procedure Register;
implementation
function TFFSRPTSTable.GenerateNewFieldName( AOwner: TComponent; const DatasetName: string; const FieldName: string ): string;
var
I: Integer;
NewName: string;
Done: Boolean;
function ComponentExists( AOwner: TComponent; const CompName: string ): Boolean;
var
I: Integer;
begin
Result := False;
for I := 0 To AOwner.ComponentCount - 1 do
begin
if AnsiCompareText( CompName, AOwner.Components[ I ].Name ) = 0 then
begin
Result := True;
Break;
end;
end;
end; { ComponentExists }
begin { TFFSRPTSTable.GenerateNewFieldName }
NewName := DatasetName;
for I := 1 to Length( FieldName ) do
begin
if FieldName[ I ] in [ '0'..'9', '_', 'A'..'Z', 'a'..'z' ] then
NewName := NewName + FieldName[ I ];
end;
if ComponentExists( Owner, NewName ) then
begin
I := 1;
Done := False;
repeat
Inc( I );
if not ComponentExists( AOwner, NewName + IntToStr( I ) ) then
begin
Result := NewName + IntToStr( I );
Done := True;
end;
until Done;
end
else
Result := NewName;
end; { TFFSRPTSTable.GenerateNewFieldName }
function TFFSRPTSTable.CreateField( const FieldName : string ): TField;
begin
{ First, try to find an existing field object. FindField is the same }
{ as FieldByName, but does not raise an exception if the field object }
{ cannot be found. }
Result := FindField( FieldName );
if Result = nil then
begin
{ If an existing field object cannot be found... }
{ Instruct the FieldDefs object to create a new field object }
Result := FieldDefs.Find( FieldName ).CreateField( Owner );
{ The new field object must be given a name so that it may appear in }
{ the Object Inspector. The Delphi default naming convention is used.}
Result.Name := GenerateNewFieldName( Owner, Name, FieldName);
end;
end; { TFFSRPTSTable.CreateField }
procedure TFFSRPTSTable.CreateFields;
begin
FDFCNumber := CreateField( 'CNumber' ) as TStringField;
FDFInstallDate := CreateField( 'InstallDate' ) as TStringField;
FDFNumberOfRuns := CreateField( 'NumberOfRuns' ) as TIntegerField;
FDFRunNumberNow := CreateField( 'RunNumberNow' ) as TIntegerField;
end; { TFFSRPTSTable.CreateFields }
procedure TFFSRPTSTable.SetActive(Value: Boolean);
begin
inherited SetActive(Value);
if Active then
CreateFields;
end; { TFFSRPTSTable.SetActive }
procedure TFFSRPTSTable.SetPCNumber(const Value: String);
begin
DFCNumber.Value := Value;
end;
function TFFSRPTSTable.GetPCNumber:String;
begin
result := DFCNumber.Value;
end;
procedure TFFSRPTSTable.SetPInstallDate(const Value: String);
begin
DFInstallDate.Value := Value;
end;
function TFFSRPTSTable.GetPInstallDate:String;
begin
result := DFInstallDate.Value;
end;
procedure TFFSRPTSTable.SetPNumberOfRuns(const Value: Integer);
begin
DFNumberOfRuns.Value := Value;
end;
function TFFSRPTSTable.GetPNumberOfRuns:Integer;
begin
result := DFNumberOfRuns.Value;
end;
procedure TFFSRPTSTable.SetPRunNumberNow(const Value: Integer);
begin
DFRunNumberNow.Value := Value;
end;
function TFFSRPTSTable.GetPRunNumberNow:Integer;
begin
result := DFRunNumberNow.Value;
end;
procedure TFFSRPTSTable.LoadFieldDefs(AStringList: TStringList);
begin
inherited;
with AstringList do
begin
Add('CNumber, String, 20, N');
Add('InstallDate, String, 10, N');
Add('NumberOfRuns, Integer, 0, N');
Add('RunNumberNow, Integer, 0, N');
end;
end;
procedure TFFSRPTSTable.LoadIndexDefs(AStringList: TStringList);
begin
inherited;
with AstringList do
begin
Add('PrimaryKey, CNumber, Y, Y, N, N');
end;
end;
procedure TFFSRPTSTable.SetEnumIndex(Value: TEIFFSRPTS);
begin
case Value of
FFSRPTSPrimaryKey : IndexName := '';
end;
end;
function TFFSRPTSTable.GetDataBuffer:TFFSRPTSRecord;
var buf: TFFSRPTSRecord;
begin
fillchar(buf, sizeof(buf), 0);
buf.PCNumber := DFCNumber.Value;
buf.PInstallDate := DFInstallDate.Value;
buf.PNumberOfRuns := DFNumberOfRuns.Value;
buf.PRunNumberNow := DFRunNumberNow.Value;
result := buf;
end;
procedure TFFSRPTSTable.StoreDataBuffer(ABuffer:TFFSRPTSRecord);
begin
DFCNumber.Value := ABuffer.PCNumber;
DFInstallDate.Value := ABuffer.PInstallDate;
DFNumberOfRuns.Value := ABuffer.PNumberOfRuns;
DFRunNumberNow.Value := ABuffer.PRunNumberNow;
end;
function TFFSRPTSTable.GetEnumIndex: TEIFFSRPTS;
var iname : string;
begin
result := FFSRPTSPrimaryKey;
iname := uppercase(indexname);
if iname = '' then result := FFSRPTSPrimaryKey;
end;
(********************************************)
(************ Register Component ************)
(********************************************)
procedure Register;
begin
RegisterComponents( 'FFS Tables', [ TFFSRPTSTable, TFFSRPTSBuffer ] );
end; { Register }
function TFFSRPTSBuffer.FieldNameToIndex(s:string):integer;
const flist:array[1..4] of string = ('CNUMBER','INSTALLDATE','NUMBEROFRUNS','RUNNUMBERNOW' );
var x : integer;
begin
s := uppercase(s);
x := 1;
while (x <= 4) and (flist[x] <> s) do inc(x);
if x <= 4 then result := x else result := 0;
end;
function TFFSRPTSBuffer.FieldType(index:integer):TFieldType;
begin
result := ftUnknown;
case index of
1 : result := ftString;
2 : result := ftString;
3 : result := ftInteger;
4 : result := ftInteger;
end;
end;
function TFFSRPTSBuffer.PtrIndex(index:integer):Pointer;
begin
result := nil;
case index of
1 : result := @Data.PCNumber;
2 : result := @Data.PInstallDate;
3 : result := @Data.PNumberOfRuns;
4 : result := @Data.PRunNumberNow;
end;
end;
end.
|
{$include lem_directives.inc}
unit LemSteel;
interface
uses
LemPiece;
type
TSteelClass = class of TSteel;
TSteel = class(TSizedPiece)
end;
type
TSteels = class(TPieces)
private
function GetItem(Index: Integer): TSteel;
procedure SetItem(Index: Integer; const Value: TSteel);
protected
public
constructor Create(aItemClass: TSteelClass);
function Add: TSteel;
function Insert(Index: Integer): TSteel;
property Items[Index: Integer]: TSteel read GetItem write SetItem; default;
end;
implementation
{ TSteels }
function TSteels.Add: TSteel;
begin
Result := TSteel(inherited Add);
end;
constructor TSteels.Create(aItemClass: TSteelClass);
begin
inherited Create(aItemClass);
end;
function TSteels.GetItem(Index: Integer): TSteel;
begin
Result := TSteel(inherited GetItem(Index))
end;
function TSteels.Insert(Index: Integer): TSteel;
begin
Result := TSteel(inherited Insert(Index))
end;
procedure TSteels.SetItem(Index: Integer; const Value: TSteel);
begin
inherited SetItem(Index, Value);
end;
end.
|
{ *********************************************************************************** }
{ * CryptoLib Library * }
{ * Copyright (c) 2018 - 20XX Ugochukwu Mmaduekwe * }
{ * Github Repository <https://github.com/Xor-el> * }
{ * Distributed under the MIT software license, see the accompanying file LICENSE * }
{ * or visit http://www.opensource.org/licenses/mit-license.php. * }
{ * Acknowledgements: * }
{ * * }
{ * Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring * }
{ * development of this library * }
{ * ******************************************************************************* * }
(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *)
unit ClpECFieldElement;
{$I ..\..\Include\CryptoLib.inc}
interface
uses
SysUtils,
ClpBits,
ClpBigInteger,
ClpBigIntegers,
ClpNat,
ClpMod,
ClpArrayUtils,
ClpLongArray,
ClpCryptoLibTypes,
ClpIECFieldElement;
resourcestring
SInvalidValue = 'Value Invalid in Fp Field Element, " x "';
SInvalidValue2 = 'Value Invalid in F2m Field Element, "x"';
SInvalidK2Value = 'k2 must be smaller than k3';
SInvalidK2Value2 = 'k2 must be larger than 0';
SInvalidFieldElement =
'Field elements are not both instances of F2mFieldElement';
SInvalidFieldElements =
'Field elements are not elements of the same field F2m';
SIncorrectRepresentation =
'One of the F2m field elements has incorrect representation';
SEvenValue = 'Even Value of Q';
STraceInternalErrorCalculation = 'Internal Error in Trace Calculation';
SHalfTraceUndefinedForM = 'Half-Trace Only Defined For Odd M';
type
TECFieldElement = class abstract(TInterfacedObject, IECFieldElement)
strict protected
function GetBitLength: Int32; virtual;
function GetIsOne: Boolean; virtual;
function GetIsZero: Boolean; virtual;
function GetFieldName: String; virtual; abstract;
function GetFieldSize: Int32; virtual; abstract;
public
constructor Create();
destructor Destroy; override;
function ToBigInteger(): TBigInteger; virtual; abstract;
function Add(const b: IECFieldElement): IECFieldElement; virtual; abstract;
function AddOne(): IECFieldElement; virtual; abstract;
function Subtract(const b: IECFieldElement): IECFieldElement;
virtual; abstract;
function Multiply(const b: IECFieldElement): IECFieldElement;
virtual; abstract;
function Divide(const b: IECFieldElement): IECFieldElement;
virtual; abstract;
function Negate(): IECFieldElement; virtual; abstract;
function Square(): IECFieldElement; virtual; abstract;
function Invert(): IECFieldElement; virtual; abstract;
function Sqrt(): IECFieldElement; virtual; abstract;
function MultiplyMinusProduct(const b, x, y: IECFieldElement)
: IECFieldElement; virtual;
function MultiplyPlusProduct(const b, x, y: IECFieldElement)
: IECFieldElement; virtual;
function SquareMinusProduct(const x, y: IECFieldElement)
: IECFieldElement; virtual;
function SquarePlusProduct(const x, y: IECFieldElement)
: IECFieldElement; virtual;
function SquarePow(pow: Int32): IECFieldElement; virtual;
function TestBitZero(): Boolean; virtual;
function Equals(const other: IECFieldElement): Boolean;
reintroduce; virtual;
function GetHashCode(): {$IFDEF DELPHI}Int32; {$ELSE}PtrInt;
{$ENDIF DELPHI}override;
function ToString(): String; override;
function GetEncoded(): TCryptoLibByteArray; virtual;
property FieldName: string read GetFieldName;
property FieldSize: Int32 read GetFieldSize;
property BitLength: Int32 read GetBitLength;
property IsOne: Boolean read GetIsOne;
property IsZero: Boolean read GetIsZero;
end;
type
TAbstractFpFieldElement = class abstract(TECFieldElement,
IAbstractFpFieldElement)
end;
type
TFpFieldElement = class(TAbstractFpFieldElement, IFpFieldElement)
strict private
Fq, Fr, Fx: TBigInteger;
function GetQ: TBigInteger; inline;
function CheckSqrt(const z: IECFieldElement): IECFieldElement; inline;
function LucasSequence(const P, Q, K: TBigInteger)
: TCryptoLibGenericArray<TBigInteger>;
strict protected
function ModAdd(const x1, x2: TBigInteger): TBigInteger; virtual;
function ModDouble(const x: TBigInteger): TBigInteger; virtual;
function ModHalf(const x: TBigInteger): TBigInteger; virtual;
function ModHalfAbs(const x: TBigInteger): TBigInteger; virtual;
function ModInverse(const x: TBigInteger): TBigInteger; virtual;
function ModMult(const x1, x2: TBigInteger): TBigInteger; virtual;
function ModReduce(const x: TBigInteger): TBigInteger; virtual;
function ModSubtract(const x1, x2: TBigInteger): TBigInteger; virtual;
/// <summary>
/// return the field name for this field.
/// </summary>
/// <returns>
/// return the string "Fp".
/// </returns>
function GetFieldName: String; override;
function GetFieldSize: Int32; override;
public
constructor Create(const Q, x: TBigInteger); overload;
deprecated 'Use ECCurve.FromBigInteger to construct field elements';
constructor Create(const Q, r, x: TBigInteger); overload;
destructor Destroy; override;
function ToBigInteger(): TBigInteger; override;
function Add(const b: IECFieldElement): IECFieldElement; override;
function AddOne(): IECFieldElement; override;
function Subtract(const b: IECFieldElement): IECFieldElement; override;
function Multiply(const b: IECFieldElement): IECFieldElement; override;
function Divide(const b: IECFieldElement): IECFieldElement; override;
function Negate(): IECFieldElement; override;
function Square(): IECFieldElement; override;
function Invert(): IECFieldElement; override;
/// <summary>
/// return a sqrt root - the routine verifies that the calculation
/// </summary>
/// <returns>
/// returns the right value - if none exists it returns null.
/// </returns>
function Sqrt(): IECFieldElement; override;
function MultiplyMinusProduct(const b, x, y: IECFieldElement)
: IECFieldElement; override;
function MultiplyPlusProduct(const b, x, y: IECFieldElement)
: IECFieldElement; override;
function SquareMinusProduct(const x, y: IECFieldElement)
: IECFieldElement; override;
function SquarePlusProduct(const x, y: IECFieldElement)
: IECFieldElement; override;
property FieldName: string read GetFieldName;
property FieldSize: Int32 read GetFieldSize;
property Q: TBigInteger read GetQ;
function Equals(const other: IFpFieldElement): Boolean; reintroduce;
function GetHashCode(): {$IFDEF DELPHI}Int32; {$ELSE}PtrInt;
{$ENDIF DELPHI}override;
class function CalculateResidue(const P: TBigInteger): TBigInteger; static;
end;
type
TAbstractF2mFieldElement = class abstract(TECFieldElement,
IAbstractF2mFieldElement)
public
function Trace(): Int32; virtual;
function HalfTrace(): IECFieldElement; virtual;
end;
type
/// **
// * Class representing the Elements of the finite field
// * <code>F<sub>2<sup>m</sup></sub></code> in polynomial basis (PB)
// * representation. Both trinomial (Tpb) and pentanomial (Ppb) polynomial
// * basis representations are supported. Gaussian normal basis (GNB)
// * representation is not supported.
// */
TF2mFieldElement = class(TAbstractF2mFieldElement, IF2mFieldElement)
strict private
var
Frepresentation, Fm: Int32;
FKs: TCryptoLibInt32Array;
Fx: TLongArray;
// /**
// * The exponent <code>m</code> of <code>F<sub>2<sup>m</sup></sub></code>.
// */
function GetM: Int32; inline;
/// <summary>
/// Tpb or Ppb.
/// </summary>
function GetRepresentation: Int32; inline;
function GetKs: TCryptoLibInt32Array; inline;
function GetX: TLongArray; inline;
function GetK1: Int32; inline;
function GetK2: Int32; inline;
function GetK3: Int32; inline;
strict protected
function GetBitLength: Int32; override;
function GetIsOne: Boolean; override;
function GetIsZero: Boolean; override;
function GetFieldName: String; override;
function GetFieldSize: Int32; override;
public
const
/// <summary>
/// Indicates gaussian normal basis representation (GNB). Number
/// chosen according to X9.62. GNB is not implemented at present. <br />
/// </summary>
Gnb = Int32(1);
/// <summary>
/// Indicates trinomial basis representation (Tpb). Number chosen
/// according to X9.62. <br />
/// </summary>
Tpb = Int32(2);
/// <summary>
/// Indicates pentanomial basis representation (Ppb). Number chosen
/// according to X9.62. <br />
/// </summary>
Ppb = Int32(3);
// /**
// * Constructor for Ppb.
// * @param m The exponent <code>m</code> of
// * <code>F<sub>2<sup>m</sup></sub></code>.
// * @param k1 The integer <code>k1</code> where <code>x<sup>m</sup> +
// * x<sup>k3</sup> + x<sup>k2</sup> + x<sup>k1</sup> + 1</code>
// * represents the reduction polynomial <code>f(z)</code>.
// * @param k2 The integer <code>k2</code> where <code>x<sup>m</sup> +
// * x<sup>k3</sup> + x<sup>k2</sup> + x<sup>k1</sup> + 1</code>
// * represents the reduction polynomial <code>f(z)</code>.
// * @param k3 The integer <code>k3</code> where <code>x<sup>m</sup> +
// * x<sup>k3</sup> + x<sup>k2</sup> + x<sup>k1</sup> + 1</code>
// * represents the reduction polynomial <code>f(z)</code>.
// * @param x The BigInteger representing the value of the field element.
// */
constructor Create(m, k1, k2, k3: Int32; const x: TBigInteger); overload;
deprecated 'Use ECCurve.FromBigInteger to construct field elements';
// /**
// * Constructor for Tpb.
// * @param m The exponent <code>m</code> of
// * <code>F<sub>2<sup>m</sup></sub></code>.
// * @param k The integer <code>k</code> where <code>x<sup>m</sup> +
// * x<sup>k</sup> + 1</code> represents the reduction
// * polynomial <code>f(z)</code>.
// * @param x The BigInteger representing the value of the field element.
// */
constructor Create(m, K: Int32; const x: TBigInteger); overload;
deprecated 'Use ECCurve.FromBigInteger to construct field elements';
constructor Create(m: Int32; const ks: TCryptoLibInt32Array;
const x: TLongArray); overload;
destructor Destroy; override;
function TestBitZero(): Boolean; override;
function ToBigInteger(): TBigInteger; override;
function Add(const b: IECFieldElement): IECFieldElement; override;
function AddOne(): IECFieldElement; override;
function Subtract(const b: IECFieldElement): IECFieldElement; override;
function Multiply(const b: IECFieldElement): IECFieldElement; override;
function Divide(const b: IECFieldElement): IECFieldElement; override;
function Negate(): IECFieldElement; override;
function Square(): IECFieldElement; override;
function Invert(): IECFieldElement; override;
/// <summary>
/// return a sqrt root - the routine verifies that the calculation
/// </summary>
/// <returns>
/// returns the right value - if none exists it returns null.
/// </returns>
function Sqrt(): IECFieldElement; override;
function MultiplyMinusProduct(const b, x, y: IECFieldElement)
: IECFieldElement; override;
function MultiplyPlusProduct(const b, x, y: IECFieldElement)
: IECFieldElement; override;
function SquareMinusProduct(const x, y: IECFieldElement)
: IECFieldElement; override;
function SquarePlusProduct(const x, y: IECFieldElement)
: IECFieldElement; override;
function SquarePow(pow: Int32): IECFieldElement; override;
function Equals(const other: IF2mFieldElement): Boolean; reintroduce;
function GetHashCode(): {$IFDEF DELPHI}Int32; {$ELSE}PtrInt;
{$ENDIF DELPHI}override;
// /**
// * Checks, if the ECFieldElements <code>a</code> and <code>b</code>
// * are elements of the same field <code>F<sub>2<sup>m</sup></sub></code>
// * (having the same representation).
// * @param a field element.
// * @param b field element to be compared.
// * @throws ArgumentException if <code>a</code> and <code>b</code>
// * are not elements of the same field
// * <code>F<sub>2<sup>m</sup></sub></code> (having the same
// * representation).
// */
class procedure CheckFieldElements(const a, b: IECFieldElement); static;
// /**
// * @return the representation of the field
// * <code>F<sub>2<sup>m</sup></sub></code>, either of
// * {@link F2mFieldElement.Tpb} (trinomial
// * basis representation) or
// * {@link F2mFieldElement.Ppb} (pentanomial
// * basis representation).
// */
property Representation: Int32 read GetRepresentation;
// /**
// * @return the degree <code>m</code> of the reduction polynomial
// * <code>f(z)</code>.
// */
property m: Int32 read GetM;
// /**
// * @return Tpb: The integer <code>k</code> where <code>x<sup>m</sup> +
// * x<sup>k</sup> + 1</code> represents the reduction polynomial
// * <code>f(z)</code>.<br/>
// * Ppb: The integer <code>k1</code> where <code>x<sup>m</sup> +
// * x<sup>k3</sup> + x<sup>k2</sup> + x<sup>k1</sup> + 1</code>
// * represents the reduction polynomial <code>f(z)</code>.<br/>
// */
property k1: Int32 read GetK1;
// /**
// * @return Tpb: Always returns <code>0</code><br/>
// * Ppb: The integer <code>k2</code> where <code>x<sup>m</sup> +
// * x<sup>k3</sup> + x<sup>k2</sup> + x<sup>k1</sup> + 1</code>
// * represents the reduction polynomial <code>f(z)</code>.<br/>
// */
property k2: Int32 read GetK2;
// /**
// * @return Tpb: Always set to <code>0</code><br/>
// * Ppb: The integer <code>k3</code> where <code>x<sup>m</sup> +
// * x<sup>k3</sup> + x<sup>k2</sup> + x<sup>k1</sup> + 1</code>
// * represents the reduction polynomial <code>f(z)</code>.<br/>
// */
property k3: Int32 read GetK3;
property ks: TCryptoLibInt32Array read GetKs;
/// <summary>
/// The <c>LongArray</c> holding the bits.
/// </summary>
property x: TLongArray read GetX;
property FieldName: string read GetFieldName;
property FieldSize: Int32 read GetFieldSize;
property BitLength: Int32 read GetBitLength;
property IsOne: Boolean read GetIsOne;
property IsZero: Boolean read GetIsZero;
end;
implementation
{ TF2mFieldElement }
function TF2mFieldElement.GetKs: TCryptoLibInt32Array;
begin
result := FKs;
end;
function TF2mFieldElement.GetM: Int32;
begin
result := Fm;
end;
function TF2mFieldElement.GetRepresentation: Int32;
begin
result := Frepresentation;
end;
function TF2mFieldElement.GetX: TLongArray;
begin
result := Fx;
end;
function TF2mFieldElement.Add(const b: IECFieldElement): IECFieldElement;
var
iarrClone: TLongArray;
bF2m: IF2mFieldElement;
begin
// No check performed here for performance reasons. Instead the
// elements involved are checked in ECPoint.F2m
// checkFieldElements(this, b);
iarrClone := Fx.Copy();
bF2m := b as IF2mFieldElement;
iarrClone.AddShiftedByWords(bF2m.x, 0);
result := TF2mFieldElement.Create(Fm, FKs, iarrClone);
end;
function TF2mFieldElement.AddOne: IECFieldElement;
begin
result := TF2mFieldElement.Create(Fm, FKs, Fx.AddOne());
end;
class procedure TF2mFieldElement.CheckFieldElements(const a,
b: IECFieldElement);
var
aF2m, bF2m: IF2mFieldElement;
begin
if (not(Supports(a, IF2mFieldElement, aF2m)) or
(not(Supports(b, IF2mFieldElement, bF2m)))) then
begin
raise EArgumentCryptoLibException.CreateRes(@SInvalidFieldElement);
end;
if (aF2m.Representation <> bF2m.Representation) then
begin
// Should never occur
raise EArgumentCryptoLibException.CreateRes(@SIncorrectRepresentation);
end;
if ((aF2m.m <> bF2m.m) or (not TArrayUtils.AreEqual(aF2m.ks, bF2m.ks))) then
begin
raise EArgumentCryptoLibException.CreateRes(@SInvalidFieldElements);
end;
end;
constructor TF2mFieldElement.Create(m, K: Int32; const x: TBigInteger);
begin
Create(m, K, 0, 0, x);
end;
constructor TF2mFieldElement.Create(m, k1, k2, k3: Int32; const x: TBigInteger);
begin
Inherited Create();
if (not(x.IsInitialized) or (x.SignValue < 0) or (x.BitLength > m)) then
begin
raise EArgumentCryptoLibException.CreateRes(@SInvalidValue2);
end;
if ((k2 = 0) and (k3 = 0)) then
begin
Frepresentation := Tpb;
FKs := TCryptoLibInt32Array.Create(k1);
end
else
begin
if (k2 >= k3) then
begin
raise EArgumentCryptoLibException.CreateRes(@SInvalidK2Value);
end;
if (k2 <= 0) then
begin
raise EArgumentCryptoLibException.CreateRes(@SInvalidK2Value2);
end;
Frepresentation := Ppb;
FKs := TCryptoLibInt32Array.Create(k1, k2, k3);
end;
Fm := m;
Fx := TLongArray.Create(x);
end;
constructor TF2mFieldElement.Create(m: Int32; const ks: TCryptoLibInt32Array;
const x: TLongArray);
begin
Inherited Create();
Fm := m;
if (System.Length(ks) = 1) then
begin
Frepresentation := Tpb
end
else
begin
Frepresentation := Ppb;
end;
FKs := ks;
Fx := x;
end;
destructor TF2mFieldElement.Destroy;
begin
inherited Destroy;
end;
function TF2mFieldElement.Divide(const b: IECFieldElement): IECFieldElement;
var
bInv: IECFieldElement;
begin
// There may be more efficient implementations
bInv := b.Invert();
result := Multiply(bInv);
end;
function TF2mFieldElement.Equals(const other: IF2mFieldElement): Boolean;
begin
if (other = Self as IF2mFieldElement) then
begin
result := true;
Exit;
end;
if (Nil = other) then
begin
result := false;
Exit;
end;
result := ((m = other.m) and (Representation = other.Representation) and
TArrayUtils.AreEqual(ks, other.ks) and (x.Equals(other.x)));
end;
function TF2mFieldElement.GetBitLength: Int32;
begin
result := Fx.Degree();
end;
function TF2mFieldElement.GetFieldName: String;
begin
result := 'F2m';
end;
function TF2mFieldElement.GetFieldSize: Int32;
begin
result := Fm;
end;
function TF2mFieldElement.GetHashCode: {$IFDEF DELPHI}Int32; {$ELSE}PtrInt;
{$ENDIF DELPHI}
begin
result := Fx.GetHashCode() xor Fm xor TArrayUtils.GetArrayHashCode(FKs);
end;
function TF2mFieldElement.GetIsOne: Boolean;
begin
result := Fx.IsOne();
end;
function TF2mFieldElement.GetIsZero: Boolean;
begin
result := Fx.IsZero();
end;
function TF2mFieldElement.GetK1: Int32;
begin
result := FKs[0];
end;
function TF2mFieldElement.GetK2: Int32;
begin
if (System.Length(FKs) >= 2) then
begin
result := FKs[1];
end
else
begin
result := 0;
end;
end;
function TF2mFieldElement.GetK3: Int32;
begin
if (System.Length(FKs) >= 3) then
begin
result := FKs[2];
end
else
begin
result := 0;
end;
end;
function TF2mFieldElement.Invert: IECFieldElement;
begin
result := TF2mFieldElement.Create(Fm, FKs, Fx.ModInverse(Fm, FKs));
end;
function TF2mFieldElement.Multiply(const b: IECFieldElement): IECFieldElement;
begin
// Right-to-left comb multiplication in the LongArray
// Input: Binary polynomials a(z) and b(z) of degree at most m-1
// Output: c(z) = a(z) * b(z) mod f(z)
// No check performed here for performance reasons. Instead the
// elements involved are checked in ECPoint.F2m
// checkFieldElements(this, b);
result := TF2mFieldElement.Create(Fm, FKs,
Fx.ModMultiply((b as IF2mFieldElement).x, Fm, FKs));
end;
function TF2mFieldElement.MultiplyMinusProduct(const b, x, y: IECFieldElement)
: IECFieldElement;
begin
result := MultiplyPlusProduct(b, x, y);
end;
function TF2mFieldElement.MultiplyPlusProduct(const b, x, y: IECFieldElement)
: IECFieldElement;
var
ax, bx, xx, yx, ab, xy: TLongArray;
begin
ax := Fx;
bx := (b as IF2mFieldElement).x;
xx := (x as IF2mFieldElement).x;
yx := (y as IF2mFieldElement).x;
ab := ax.Multiply(bx, Fm, FKs);
xy := xx.Multiply(yx, Fm, FKs);
if ((ab.Equals(ax)) or (ab.Equals(bx))) then
begin
ab := ab.Copy();
end;
ab.AddShiftedByWords(xy, 0);
ab.Reduce(Fm, FKs);
result := TF2mFieldElement.Create(Fm, FKs, ab);
end;
function TF2mFieldElement.Negate: IECFieldElement;
begin
// -x == x holds for all x in F2m
result := Self as IECFieldElement;
end;
function TF2mFieldElement.Sqrt: IECFieldElement;
begin
if ((Fx.IsZero()) or (Fx.IsOne())) then
begin
result := Self as IECFieldElement;
end
else
begin
result := SquarePow(Fm - 1);
end;
end;
function TF2mFieldElement.Square: IECFieldElement;
begin
result := TF2mFieldElement.Create(Fm, FKs, Fx.ModSquare(Fm, FKs));
end;
function TF2mFieldElement.SquareMinusProduct(const x, y: IECFieldElement)
: IECFieldElement;
begin
result := SquarePlusProduct(x, y);
end;
function TF2mFieldElement.SquarePlusProduct(const x, y: IECFieldElement)
: IECFieldElement;
var
ax, xx, yx, aa, xy: TLongArray;
begin
ax := Fx;
xx := (x as IF2mFieldElement).x;
yx := (y as IF2mFieldElement).x;
aa := ax.Square(Fm, FKs);
xy := xx.Multiply(yx, Fm, FKs);
if (aa.Equals(ax)) then
begin
aa := aa.Copy();
end;
aa.AddShiftedByWords(xy, 0);
aa.Reduce(Fm, FKs);
result := TF2mFieldElement.Create(Fm, FKs, aa);
end;
function TF2mFieldElement.SquarePow(pow: Int32): IECFieldElement;
begin
if pow < 1 then
begin
result := Self as IECFieldElement
end
else
begin
result := TF2mFieldElement.Create(Fm, FKs, Fx.ModSquareN(pow, Fm, FKs));
end;
end;
function TF2mFieldElement.Subtract(const b: IECFieldElement): IECFieldElement;
begin
// Addition and subtraction are the same in F2m
result := Add(b);
end;
function TF2mFieldElement.TestBitZero: Boolean;
begin
result := Fx.TestBitZero();
end;
function TF2mFieldElement.ToBigInteger: TBigInteger;
begin
result := Fx.ToBigInteger();
end;
{ TECFieldElement }
constructor TECFieldElement.Create;
begin
Inherited Create();
end;
destructor TECFieldElement.Destroy;
begin
inherited Destroy;
end;
function TECFieldElement.Equals(const other: IECFieldElement): Boolean;
begin
if (other = Self as IECFieldElement) then
begin
result := true;
Exit;
end;
if (Nil = other) then
begin
result := false;
Exit;
end;
result := ToBigInteger().Equals(other.ToBigInteger());
end;
function TECFieldElement.GetBitLength: Int32;
begin
result := ToBigInteger().BitLength;
end;
function TECFieldElement.GetEncoded: TCryptoLibByteArray;
begin
result := TBigIntegers.AsUnsignedByteArray((FieldSize + 7) div 8,
ToBigInteger());
end;
function TECFieldElement.GetHashCode: {$IFDEF DELPHI}Int32; {$ELSE}PtrInt;
{$ENDIF DELPHI}
begin
result := ToBigInteger().GetHashCode();
end;
function TECFieldElement.GetIsOne: Boolean;
begin
result := BitLength = 1;
end;
function TECFieldElement.GetIsZero: Boolean;
begin
result := 0 = ToBigInteger().SignValue;
end;
function TECFieldElement.MultiplyMinusProduct(const b, x, y: IECFieldElement)
: IECFieldElement;
begin
result := Multiply(b).Subtract(x.Multiply(y));
end;
function TECFieldElement.MultiplyPlusProduct(const b, x, y: IECFieldElement)
: IECFieldElement;
begin
result := Multiply(b).Add(x.Multiply(y));
end;
function TECFieldElement.SquareMinusProduct(const x, y: IECFieldElement)
: IECFieldElement;
begin
result := Square().Subtract(x.Multiply(y));
end;
function TECFieldElement.SquarePlusProduct(const x, y: IECFieldElement)
: IECFieldElement;
begin
result := Square().Add(x.Multiply(y));
end;
function TECFieldElement.SquarePow(pow: Int32): IECFieldElement;
var
r: IECFieldElement;
i: Int32;
begin
r := Self as IECFieldElement;
i := 0;
while i < pow do
begin
r := r.Square();
System.Inc(i);
end;
result := r;
end;
function TECFieldElement.TestBitZero: Boolean;
begin
result := ToBigInteger().TestBit(0);
end;
function TECFieldElement.ToString: String;
begin
result := ToBigInteger().ToString(16);
end;
{ TFpFieldElement }
function TFpFieldElement.GetQ: TBigInteger;
begin
result := Fq;
end;
function TFpFieldElement.GetFieldSize: Int32;
begin
result := Q.BitLength;
end;
function TFpFieldElement.Add(const b: IECFieldElement): IECFieldElement;
begin
result := TFpFieldElement.Create(Fq, Fr, ModAdd(Fx, b.ToBigInteger()));
end;
function TFpFieldElement.AddOne: IECFieldElement;
var
x2: TBigInteger;
begin
x2 := Fx.Add(TBigInteger.One);
if (x2.CompareTo(Q) = 0) then
begin
x2 := TBigInteger.Zero;
end;
result := TFpFieldElement.Create(Fq, Fr, x2);
end;
class function TFpFieldElement.CalculateResidue(const P: TBigInteger)
: TBigInteger;
var
BitLength: Int32;
firstWord: TBigInteger;
begin
BitLength := P.BitLength;
if (BitLength >= 96) then
begin
firstWord := P.ShiftRight(BitLength - 64);
if (firstWord.Int64Value = Int64(-1)) then
begin
result := TBigInteger.One.ShiftLeft(BitLength).Subtract(P);
Exit;
end;
if ((BitLength and 7) = 0) then
begin
result := TBigInteger.One.ShiftLeft(BitLength shl 1).Divide(P).Negate();
Exit;
end;
end;
result := Default (TBigInteger);
end;
function TFpFieldElement.CheckSqrt(const z: IECFieldElement): IECFieldElement;
begin
if (z.Square().Equals(Self as IECFieldElement)) then
begin
result := z;
end
else
begin
result := Nil;
end;
end;
constructor TFpFieldElement.Create(const Q, x: TBigInteger);
begin
Create(Q, CalculateResidue(Q), x);
end;
constructor TFpFieldElement.Create(const Q, r, x: TBigInteger);
begin
Inherited Create();
if (not(x.IsInitialized) or (x.SignValue < 0) or (x.CompareTo(Q) >= 0)) then
begin
raise EArgumentCryptoLibException.CreateRes(@SInvalidValue);
end;
Fq := Q;
Fr := r;
Fx := x;
end;
destructor TFpFieldElement.Destroy;
begin
inherited Destroy;
end;
function TFpFieldElement.Divide(const b: IECFieldElement): IECFieldElement;
begin
result := TFpFieldElement.Create(Fq, Fr,
ModMult(Fx, ModInverse(b.ToBigInteger())));
end;
function TFpFieldElement.Equals(const other: IFpFieldElement): Boolean;
begin
if (other = Self as IFpFieldElement) then
begin
result := true;
Exit;
end;
if (other = Nil) then
begin
result := false;
Exit;
end;
result := (Q.Equals(other.Q) and (Inherited Equals(other)));
end;
function TFpFieldElement.GetFieldName: String;
begin
result := 'Fp';
end;
function TFpFieldElement.GetHashCode: {$IFDEF DELPHI}Int32; {$ELSE}PtrInt;
{$ENDIF DELPHI}
begin
result := Q.GetHashCode() xor (Inherited GetHashCode());
end;
function TFpFieldElement.Invert: IECFieldElement;
begin
// TODO Modular inversion can be faster for a (Generalized) Mersenne Prime.
result := TFpFieldElement.Create(Fq, Fr, ModInverse(Fx));
end;
function TFpFieldElement.LucasSequence(const P, Q, K: TBigInteger)
: TCryptoLibGenericArray<TBigInteger>;
var
n, s, j: Int32;
Uh, Vl, Vh, Ql, Qh: TBigInteger;
begin
// TODO Research and apply "common-multiplicand multiplication here"
n := K.BitLength;
s := K.GetLowestSetBit();
{$IFDEF DEBUG}
System.Assert(K.TestBit(s));
{$ENDIF DEBUG}
Uh := TBigInteger.One;
Vl := TBigInteger.Two;
Vh := P;
Ql := TBigInteger.One;
Qh := TBigInteger.One;
j := n - 1;
while j >= s + 1 do
begin
Ql := ModMult(Ql, Qh);
if (K.TestBit(j)) then
begin
Qh := ModMult(Ql, Q);
Uh := ModMult(Uh, Vh);
Vl := ModReduce(Vh.Multiply(Vl).Subtract(P.Multiply(Ql)));
Vh := ModReduce(Vh.Multiply(Vh).Subtract(Qh.ShiftLeft(1)));
end
else
begin
Qh := Ql;
Uh := ModReduce(Uh.Multiply(Vl).Subtract(Ql));
Vh := ModReduce(Vh.Multiply(Vl).Subtract(P.Multiply(Ql)));
Vl := ModReduce(Vl.Multiply(Vl).Subtract(Ql.ShiftLeft(1)));
end;
System.Dec(j);
end;
Ql := ModMult(Ql, Qh);
Qh := ModMult(Ql, Q);
Uh := ModReduce(Uh.Multiply(Vl).Subtract(Ql));
Vl := ModReduce(Vh.Multiply(Vl).Subtract(P.Multiply(Ql)));
Ql := ModMult(Ql, Qh);
j := 1;
while j <= s do
begin
Uh := ModMult(Uh, Vl);
Vl := ModReduce(Vl.Multiply(Vl).Subtract(Ql.ShiftLeft(1)));
Ql := ModMult(Ql, Ql);
System.Inc(j);
end;
result := TCryptoLibGenericArray<TBigInteger>.Create(Uh, Vl);
end;
function TFpFieldElement.ModAdd(const x1, x2: TBigInteger): TBigInteger;
var
x3: TBigInteger;
begin
x3 := x1.Add(x2);
if (x3.CompareTo(Q) >= 0) then
begin
x3 := x3.Subtract(Q);
end;
result := x3;
end;
function TFpFieldElement.ModDouble(const x: TBigInteger): TBigInteger;
var
_2x: TBigInteger;
begin
_2x := x.ShiftLeft(1);
if (_2x.CompareTo(Q) >= 0) then
begin
_2x := _2x.Subtract(Q);
end;
result := _2x;
end;
function TFpFieldElement.ModHalf(const x: TBigInteger): TBigInteger;
var
Lx: TBigInteger;
begin
Lx := x;
if (Lx.TestBit(0)) then
begin
Lx := Q.Add(Lx);
end;
result := Lx.ShiftRight(1);
end;
function TFpFieldElement.ModHalfAbs(const x: TBigInteger): TBigInteger;
var
Lx: TBigInteger;
begin
Lx := x;
if (Lx.TestBit(0)) then
begin
Lx := Q.Subtract(Lx);
end;
result := Lx.ShiftRight(1);
end;
function TFpFieldElement.ModInverse(const x: TBigInteger): TBigInteger;
var
bits, len: Int32;
P, n, z: TCryptoLibUInt32Array;
begin
bits := FieldSize;
len := TBits.Asr32((bits + 31), 5);
P := TNat.FromBigInteger(bits, Q);
n := TNat.FromBigInteger(bits, x);
z := TNat.Create(len);
TMod.Invert(P, n, z);
result := TNat.ToBigInteger(len, z);
end;
function TFpFieldElement.ModMult(const x1, x2: TBigInteger): TBigInteger;
begin
result := ModReduce(x1.Multiply(x2));
end;
function TFpFieldElement.ModReduce(const x: TBigInteger): TBigInteger;
var
negative, rIsOne: Boolean;
qLen, d: Int32;
qMod, u, v, mu, quot, bk1, Lx: TBigInteger;
begin
Lx := x;
if (not(Fr.IsInitialized)) then
begin
Lx := Lx.&Mod(Q);
end
else
begin
negative := Lx.SignValue < 0;
if (negative) then
begin
Lx := Lx.Abs();
end;
qLen := Q.BitLength;
if (Fr.SignValue > 0) then
begin
qMod := TBigInteger.One.ShiftLeft(qLen);
rIsOne := Fr.Equals(TBigInteger.One);
while (Lx.BitLength > (qLen + 1)) do
begin
u := Lx.ShiftRight(qLen);
v := Lx.Remainder(qMod);
if (not rIsOne) then
begin
u := u.Multiply(Fr);
end;
Lx := u.Add(v);
end
end
else
begin
d := ((qLen - 1) and 31) + 1;
mu := Fr.Negate();
u := mu.Multiply(Lx.ShiftRight(qLen - d));
quot := u.ShiftRight(qLen + d);
v := quot.Multiply(Q);
bk1 := TBigInteger.One.ShiftLeft(qLen + d);
v := v.Remainder(bk1);
Lx := Lx.Remainder(bk1);
Lx := Lx.Subtract(v);
if (Lx.SignValue < 0) then
begin
Lx := Lx.Add(bk1);
end
end;
while (Lx.CompareTo(Q) >= 0) do
begin
Lx := Lx.Subtract(Q);
end;
if ((negative) and (Lx.SignValue <> 0)) then
begin
Lx := Q.Subtract(Lx);
end;
end;
result := Lx;
end;
function TFpFieldElement.ModSubtract(const x1, x2: TBigInteger): TBigInteger;
var
x3: TBigInteger;
begin
x3 := x1.Subtract(x2);
if (x3.SignValue < 0) then
begin
x3 := x3.Add(Q);
end;
result := x3;
end;
function TFpFieldElement.Multiply(const b: IECFieldElement): IECFieldElement;
begin
result := TFpFieldElement.Create(Fq, Fr, ModMult(Fx, b.ToBigInteger()));
end;
function TFpFieldElement.MultiplyMinusProduct(const b, x, y: IECFieldElement)
: IECFieldElement;
var
ax, bx, xx, yx, ab, xy: TBigInteger;
begin
ax := Fx;
bx := b.ToBigInteger();
xx := x.ToBigInteger();
yx := y.ToBigInteger();
ab := ax.Multiply(bx);
xy := xx.Multiply(yx);
result := TFpFieldElement.Create(Fq, Fr, ModReduce(ab.Subtract(xy)));
end;
function TFpFieldElement.MultiplyPlusProduct(const b, x, y: IECFieldElement)
: IECFieldElement;
var
ax, bx, xx, yx, ab, xy, sum: TBigInteger;
begin
ax := Fx;
bx := b.ToBigInteger();
xx := x.ToBigInteger();
yx := y.ToBigInteger();
ab := ax.Multiply(bx);
xy := xx.Multiply(yx);
sum := ab.Add(xy);
if ((Fr.IsInitialized) and (Fr.SignValue < 0) and
(sum.BitLength > (Fq.BitLength shl 1))) then
begin
sum := sum.Subtract(Fq.ShiftLeft(Q.BitLength));
end;
result := TFpFieldElement.Create(Fq, Fr, ModReduce(sum));
end;
function TFpFieldElement.Negate: IECFieldElement;
begin
if Fx.SignValue = 0 then
begin
result := Self as IECFieldElement
end
else
begin
result := TFpFieldElement.Create(Fq, Fr, Fq.Subtract(Fx));
end;
end;
function TFpFieldElement.Sqrt: IECFieldElement;
var
u, v, K, e, t1, t2, t3, t4, y, legendreExponent, x, fourX, qMinusOne,
P: TBigInteger;
tempRes: TCryptoLibGenericArray<TBigInteger>;
CompareRes, ModReduceRes: Boolean;
begin
if (IsZero or IsOne) then
begin
result := Self as IECFieldElement;
Exit;
end;
if (not Fq.TestBit(0)) then
begin
raise ENotImplementedCryptoLibException.CreateRes(@SEvenValue);
end;
if (Fq.TestBit(1)) then // q == 4m + 3
begin
e := Fq.ShiftRight(2).Add(TBigInteger.One);
result := CheckSqrt(TFpFieldElement.Create(Fq, Fr, Fx.ModPow(e, Fq))
as IFpFieldElement);
Exit;
end;
if (Fq.TestBit(2)) then // q == 8m + 5
begin
t1 := Fx.ModPow(Fq.ShiftRight(3), Fq);
t2 := ModMult(t1, Fx);
t3 := ModMult(t2, t1);
if (t3.Equals(TBigInteger.One)) then
begin
result := CheckSqrt(TFpFieldElement.Create(Fq, Fr, t2)
as IFpFieldElement);
Exit;
end;
// TODO This is constant and could be precomputed
t4 := TBigInteger.Two.ModPow(Fq.ShiftRight(2), Fq);
y := ModMult(t2, t4);
result := CheckSqrt(TFpFieldElement.Create(Fq, Fr, y) as IFpFieldElement);
Exit;
end;
// q == 8m + 1
legendreExponent := Fq.ShiftRight(1);
if (not(Fx.ModPow(legendreExponent, Fq).Equals(TBigInteger.One))) then
begin
result := Nil;
Exit;
end;
x := Fx;
fourX := ModDouble(ModDouble(x));
K := legendreExponent.Add(TBigInteger.One);
qMinusOne := Fq.Subtract(TBigInteger.One);
repeat
repeat
P := TBigInteger.Arbitrary(Fq.BitLength);
CompareRes := P.CompareTo(Q) >= 0;
ModReduceRes := (not ModReduce(P.Multiply(P).Subtract(fourX))
.ModPow(legendreExponent, Q).Equals(qMinusOne));
until ((not CompareRes) and (not ModReduceRes));
tempRes := LucasSequence(P, x, K);
u := tempRes[0];
v := tempRes[1];
if (ModMult(v, v).Equals(fourX)) then
begin
result := TFpFieldElement.Create(Fq, Fr, ModHalfAbs(v));
Exit;
end;
until ((not u.Equals(TBigInteger.One)) or (not u.Equals(qMinusOne)));
result := Nil;
end;
function TFpFieldElement.Square: IECFieldElement;
begin
result := TFpFieldElement.Create(Fq, Fr, ModMult(Fx, Fx));
end;
function TFpFieldElement.SquareMinusProduct(const x, y: IECFieldElement)
: IECFieldElement;
var
ax, xx, yx, aa, xy: TBigInteger;
begin
ax := Fx;
xx := x.ToBigInteger();
yx := y.ToBigInteger();
aa := ax.Multiply(ax);
xy := xx.Multiply(yx);
result := TFpFieldElement.Create(Fq, Fr, ModReduce(aa.Subtract(xy)));
end;
function TFpFieldElement.SquarePlusProduct(const x, y: IECFieldElement)
: IECFieldElement;
var
ax, xx, yx, aa, xy, sum: TBigInteger;
begin
ax := Fx;
xx := x.ToBigInteger();
yx := y.ToBigInteger();
aa := ax.Multiply(ax);
xy := xx.Multiply(yx);
sum := aa.Add(xy);
if ((Fr.IsInitialized) and (Fr.SignValue < 0) and
(sum.BitLength > (Fq.BitLength shl 1))) then
begin
sum := sum.Subtract(Fq.ShiftLeft(Fq.BitLength));
end;
result := TFpFieldElement.Create(Fq, Fr, ModReduce(sum));
end;
function TFpFieldElement.Subtract(const b: IECFieldElement): IECFieldElement;
begin
result := TFpFieldElement.Create(Fq, Fr, ModSubtract(Fx, b.ToBigInteger()));
end;
function TFpFieldElement.ToBigInteger: TBigInteger;
begin
result := Fx;
end;
{ TAbstract2mFieldElement }
function TAbstractF2mFieldElement.HalfTrace: IECFieldElement;
var
m, i: Int32;
fe, ht: IECFieldElement;
begin
m := FieldSize;
if ((m and 1) = 0) then
begin
raise EArgumentCryptoLibException.CreateRes(@SHalfTraceUndefinedForM);
end;
fe := Self as IECFieldElement;
ht := fe;
i := 2;
while i < m do
begin
fe := fe.SquarePow(2);
ht := ht.Add(fe);
System.Inc(i, 2);
end;
result := ht;
end;
function TAbstractF2mFieldElement.Trace: Int32;
var
m, i: Int32;
fe, tr: IECFieldElement;
begin
m := FieldSize;
fe := Self as IECFieldElement;
tr := fe;
i := 1;
while i < m do
begin
fe := fe.Square();
tr := tr.Add(fe);
System.Inc(i);
end;
if (tr.IsZero) then
begin
result := 0;
Exit;
end;
if (tr.IsOne) then
begin
result := 1;
Exit;
end;
raise EArgumentCryptoLibException.CreateRes(@STraceInternalErrorCalculation);
end;
end.
|
unit ADLSUnitTest.Classes;
interface
uses
DUnitX.TestFramework, ADLSConnector.Interfaces, ADLSFileManager.Interfaces,
ADLSConnector.Presenter, ADLSFileManager.Presenter,
System.Generics.Collections, IPPeerCommon;
type
TADLSFakeView = class(TInterfacedObject, IADLSConnectorView, IADLSFileManagerView)
protected
FBaseURL: string;
FClientID: string;
FClientSecret: string;
FAccessTokenEndpoint: string;
FAuthorizationEndpoint: string;
FFMBaseURL: string;
FFMDirectory: string;
FFMFilePath: string;
FFMDirectories: TList<string>;
FADLSConnectorP: IADLSConnectorPresenter;
FADLSFileManagerP: IADLSFileManagerPresenter;
public
constructor Create(const ABaseURL, AClientID, AClientSecret, AAccessTokenEndpoint,
AAuthorizationEndpoint, AFMBaseURL: string);
//destructor Destroy; override;
// Input connector
function GetBaseURL: string;
function GetClientID: string;
function GetClientSecret: string;
function GetAccessTokenEndpoint: string;
function GetAuthorizationEndpoint: string;
// Input file manager
function GetFMBaseURL: string;
function GetFMDirectory: string;
function GetFMFilePath: string;
// Output connector
procedure SetAccessToken(const AValue: string);
procedure SetResponseData(const AValue: string);
procedure AddResponseData(const AValue: string);
// Output file manager
procedure DisplayFMMessage(AValue: string);
procedure SetFMDirectory(AValue: TList<string>);
procedure SetFMResponseData(const AValue: string);
procedure AddFMResponseData(const AValue: string);
procedure GetAccessToken;
end;
[TestFixture]
TADLSUnitTest = class(TObject)
protected
FBaseURL: string;
FClientID: string;
FClientSecret: string;
FAccessTokenEndpoint: string;
FAuthorizationEndpoint: string;
FFMBaseURL: string;
public
[Setup]
procedure Setup;
[TearDown]
procedure TearDown;
// Sample Methods
// Simple single Test
//[Test]
//procedure Test1;
// Test with TestCase Atribute to supply parameters.
//[Test]
//[TestCase('TestA','1,2')]
//[TestCase('TestB','3,4')]
//procedure Test2(const AValue1 : Integer;const AValue2 : Integer);
[Test]
procedure GetAccessToken;
[Test]
procedure ListFolders;
end;
implementation
uses
System.SysUtils;
procedure TADLSUnitTest.GetAccessToken;
var
LADLSFakeView: TADLSFakeView;
begin
LADLSFakeView := TADLSFakeView.Create(FBaseURL, FClientID, FClientSecret,
FAccessTokenEndpoint, FAuthorizationEndpoint, FFMBaseURL);
try
LADLSFakeView.GetAccessToken;
if (LADLSFakeView.FADLSConnectorP.AccessToken = '') then
raise Exception.Create('Error retrieving the access token');
finally
//LADLSFakeView.Free;
end;
end;
procedure TADLSUnitTest.ListFolders;
var
LADLSFakeView: TADLSFakeView;
begin
LADLSFakeView := TADLSFakeView.Create(FBaseURL, FClientID, FClientSecret,
FAccessTokenEndpoint, FAuthorizationEndpoint, FFMBaseURL);
try
LADLSFakeView.FADLSConnectorP.GetAccessToken;
if (LADLSFakeView.FADLSConnectorP.AccessToken = '') then
raise Exception.Create('Error retrieving the access token');
LADLSFakeView.FADLSFileManagerP.ListFolders;
if (LADLSFakeView.FADLSFileManagerP.GetListFolders.Text = '') then
raise Exception.Create('Error retrieving the list folders');
finally
//LADLSFakeView.Free;
end;
end;
procedure TADLSUnitTest.Setup;
begin
FBaseURL := '';
FClientID := '';
FClientSecret := '';
FAccessTokenEndpoint := 'https://login.windows.net/<TENANTID or DIRECTORYID>/oauth2/token';
FAuthorizationEndpoint := '';
FFMBaseURL := 'https://<DATA LAKE STORE NAME>.azuredatalakestore.net';
end;
procedure TADLSUnitTest.TearDown;
begin
end;
//procedure TADLSUnitTest.Test1;
//begin
//end;
//procedure TADLSUnitTest.Test2(const AValue1 : Integer;const AValue2 : Integer);
//begin
//end;
{ TADLSFakeView }
procedure TADLSFakeView.AddFMResponseData(const AValue: string);
begin
System.Write(AValue);
end;
procedure TADLSFakeView.AddResponseData(const AValue: string);
begin
System.Write(AValue);
end;
constructor TADLSFakeView.Create(const ABaseURL, AClientID, AClientSecret,
AAccessTokenEndpoint, AAuthorizationEndpoint, AFMBaseURL: string);
begin
// Connector
FBaseURL := ABaseURL;
FClientID := AClientID;
FClientSecret := AClientSecret;
FAccessTokenEndpoint := AAccessTokenEndpoint;
FAuthorizationEndpoint := AAuthorizationEndpoint;
// File Manager
FFMBaseURL := AFMBaseURL;
FFMDirectories := TList<string>.Create;
FADLSConnectorP := TADLSConnectorPresenter.Create(Self);
FADLSFileManagerP := TADLSFileManagerPresenter.Create(FADLSConnectorP, Self);
end;
//destructor TADLSFakeView.Destroy;
//begin
// // Interfaces are released automatically
// //FADLSFileManagerP.Free;
// //FADLSConnectorP.Free;
//
// inherited;
//end;
procedure TADLSFakeView.DisplayFMMessage(AValue: string);
begin
System.Write(AValue);
end;
procedure TADLSFakeView.GetAccessToken;
begin
FADLSConnectorP.GetAccessToken;
end;
function TADLSFakeView.GetAccessTokenEndpoint: string;
begin
Result := FAccessTokenEndpoint;
end;
function TADLSFakeView.GetAuthorizationEndpoint: string;
begin
Result := FAuthorizationEndpoint;
end;
function TADLSFakeView.GetBaseURL: string;
begin
Result := FBaseURL;
end;
function TADLSFakeView.GetClientID: string;
begin
Result := FClientID;
end;
function TADLSFakeView.GetClientSecret: string;
begin
Result := FClientSecret;
end;
function TADLSFakeView.GetFMBaseURL: string;
begin
Result := FFMBaseURL;
end;
function TADLSFakeView.GetFMDirectory: string;
begin
end;
function TADLSFakeView.GetFMFilePath: string;
begin
end;
procedure TADLSFakeView.SetAccessToken(const AValue: string);
begin
System.Write('');
System.Write('Access token..');
System.Write(AValue);
end;
procedure TADLSFakeView.SetFMDirectory(AValue: TList<string>);
var
i: Integer;
begin
FFMDirectories.Clear;
for i := 0 to AValue.Count - 1 do
FFMDirectories.Add(AValue.Items[i]);
end;
procedure TADLSFakeView.SetFMResponseData(const AValue: string);
begin
end;
procedure TADLSFakeView.SetResponseData(const AValue: string);
begin
System.Write('');
System.Write(GetBaseURL);
System.Write(AValue);
end;
initialization
TDUnitX.RegisterTestFixture(TADLSUnitTest);
end.
|
unit OreStorage;
interface
uses
Warehouses, Kernel, Surfaces, WorkCenterBlock, BackupInterfaces, CacheAgent;
type
TMetaOreStorage =
class(TMetaWarehouse)
public
constructor Create(anId : string;
aCapacities : array of TFluidValue;
aOreMax : TFluidValue;
aMetalMax : TFluidValue;
aConstMax : TFluidValue;
aTimberMax : TFluidValue;
theOverPrice : TPercent;
aBlockClass : CBlock);
end;
TOreStorage =
class(TWarehouse)
private
fOreIn : TInputData;
fOreChemsIn : TInputData;
fOreSiliconIn : TInputData;
fOreStoneIn : TInputData;
fOreCoalIn : TInputData;
fMetalIn : TInputData;
fConstIn : TInputData;
fTimberIn : TInputData;
fOreOut : TOutputData;
fOreChemsOut : TOutputData;
fOreSiliconOut : TOutputData;
fOreStoneOut : TOutputData;
fOreCoalOut : TOutputData;
fMetalOut : TOutputData;
fConstOut : TOutputData;
fTimberOut : TOutputData;
end;
procedure RegisterBackup;
implementation
uses
ClassStorage, StdFluids;
// TMetaOreStorage
constructor TMetaOreStorage.Create(anId : string;
aCapacities : array of TFluidValue;
aOreMax : TFluidValue;
aMetalMax : TFluidValue;
aConstMax : TFluidValue;
aTimberMax : TFluidValue;
theOverPrice : TPercent;
aBlockClass : CBlock);
var
Sample : TOreStorage;
begin
inherited Create(anId, aCapacities, aBlockClass);
Sample := nil;
// Inputs
NewMetaInput(
tidGate_Ore,
tidFluid_Ore,
aOreMax,
sizeof(Sample.fOreIn),
Sample.Offset(Sample.fOreIn));
NewMetaInput(
tidGate_OreChems,
tidFluid_OreChems,
aOreMax,
sizeof(Sample.fOreChemsIn),
Sample.Offset(Sample.fOreChemsIn));
NewMetaInput(
tidGate_OreSilicon,
tidFluid_OreSilicon,
aOreMax,
sizeof(Sample.fOreSiliconIn),
Sample.Offset(Sample.fOreSiliconIn));
NewMetaInput(
tidGate_OreStone,
tidFluid_OreStone,
aOreMax,
sizeof(Sample.fOreStoneIn),
Sample.Offset(Sample.fOreStoneIn));
NewMetaInput(
tidGate_OreCoal,
tidFluid_OreCoal,
aOreMax,
sizeof(Sample.fOreCoalIn),
Sample.Offset(Sample.fOreCoalIn));
NewMetaInput(
tidGate_Metals,
tidFluid_Metals,
aMetalMax,
sizeof(Sample.fMetalIn),
Sample.Offset(Sample.fMetalIn));
NewMetaInput(
tidGate_ConstructionForce,
tidFluid_ConstructionForce,
aConstMax,
sizeof(Sample.fConstIn),
Sample.Offset(Sample.fConstIn));
NewMetaInput(
tidGate_Timber,
tidFluid_Timber,
aTimberMax,
sizeof(Sample.fTimberIn),
Sample.Offset(Sample.fTimberIn));
// Outputs
NewMetaOutput(
tidGate_Ore,
tidFluid_Ore,
aOreMax,
sizeof(Sample.fOreOut),
Sample.Offset(Sample.fOreOut));
NewMetaOutput(
tidGate_OreChems,
tidFluid_OreChems,
aOreMax,
sizeof(Sample.fOreChemsOut),
Sample.Offset(Sample.fOreChemsOut));
NewMetaOutput(
tidGate_OreSilicon,
tidFluid_OreSilicon,
aOreMax,
sizeof(Sample.fOreSiliconOut),
Sample.Offset(Sample.fOreSiliconOut));
NewMetaOutput(
tidGate_OreStone,
tidFluid_OreStone,
aOreMax,
sizeof(Sample.fOreStoneOut),
Sample.Offset(Sample.fOreStoneOut));
NewMetaOutput(
tidGate_OreCoal,
tidFluid_OreCoal,
aOreMax,
sizeof(Sample.fOreCoalOut),
Sample.Offset(Sample.fOreCoalOut));
NewMetaOutput(
tidGate_Metals,
tidFluid_Metals,
aMetalMax,
sizeof(Sample.fMetalOut),
Sample.Offset(Sample.fMetalOut));
NewMetaOutput(
tidGate_ConstructionForce,
tidFluid_ConstructionForce,
aConstMax,
sizeof(Sample.fConstOut),
Sample.Offset(Sample.fConstOut));
NewMetaOutput(
tidGate_Timber,
tidFluid_Timber,
aTimberMax,
sizeof(Sample.fTimberOut),
Sample.Offset(Sample.fTimberOut));
// Wares
RegisterWare(tidGate_Ore, 15, 0, theOverPrice, aOreMax);
RegisterWare(tidGate_OreChems, 15, 0, theOverPrice, aOreMax);
RegisterWare(tidGate_OreSilicon, 16, 0, theOverPrice, aOreMax);
RegisterWare(tidGate_OreStone, 17, 0, theOverPrice, aOreMax);
RegisterWare(tidGate_OreCoal, 17, 0, theOverPrice, aOreMax);
RegisterWare(tidGate_Metals, 20, 0, theOverPrice, aMetalMax);
RegisterWare(tidGate_ConstructionForce, 20, 0, theOverPrice, aConstMax);
RegisterWare(tidGate_Timber, 20, 0, theOverPrice, aTimberMax);
end;
// Register backup
procedure RegisterBackup;
begin
BackupInterfaces.RegisterClass(TOreStorage);
end;
end.
|
unit DeleteRoutesUnit;
interface
uses SysUtils, BaseExampleUnit, CommonTypesUnit;
type
TDeleteRoutes = class(TBaseExample)
public
procedure Execute(RouteIds: TStringArray);
end;
implementation
procedure TDeleteRoutes.Execute(RouteIds: TStringArray);
var
ErrorString: String;
DeletedRouteIds: TStringArray;
begin
DeletedRouteIds := Route4MeManager.Route.Delete(RouteIds, ErrorString);
WriteLn('');
if (Length(DeletedRouteIds) > 0) then
begin
WriteLn(Format('DeleteRoutes executed successfully, %d routes deleted',
[Length(DeletedRouteIds)]));
WriteLn('');
end
else
WriteLn(Format('DeleteRoutes error "%s"', [ErrorString]));
end;
end.
|
{ *********************************************************************************** }
{ * CryptoLib Library * }
{ * Copyright (c) 2018 - 20XX Ugochukwu Mmaduekwe * }
{ * Github Repository <https://github.com/Xor-el> * }
{ * Distributed under the MIT software license, see the accompanying file LICENSE * }
{ * or visit http://www.opensource.org/licenses/mit-license.php. * }
{ * Acknowledgements: * }
{ * * }
{ * Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring * }
{ * development of this library * }
{ * ******************************************************************************* * }
(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *)
unit ClpSecT283K1Point;
{$I ..\..\..\..\Include\CryptoLib.inc}
interface
uses
ClpECPoint,
ClpISecT283K1Point,
ClpIECFieldElement,
ClpIECInterface,
ClpBigInteger,
ClpCryptoLibTypes;
resourcestring
SOneOfECFieldElementIsNil = 'Exactly One of the Field Elements is Nil';
type
TSecT283K1Point = class sealed(TAbstractF2mPoint, ISecT283K1Point)
strict protected
function Detach(): IECPoint; override;
function GetCompressionYTilde: Boolean; override;
property CompressionYTilde: Boolean read GetCompressionYTilde;
public
/// <summary>
/// Create a point which encodes without point compression.
/// </summary>
/// <param name="curve">
/// the curve to use
/// </param>
/// <param name="x">
/// affine x co-ordinate
/// </param>
/// <param name="y">
/// affine y co-ordinate
/// </param>
constructor Create(const curve: IECCurve; const x, y: IECFieldElement);
overload; deprecated 'Use ECCurve.createPoint to construct points';
/// <summary>
/// Create a point that encodes with or without point compresion.
/// </summary>
/// <param name="curve">
/// the curve to use
/// </param>
/// <param name="x">
/// affine x co-ordinate
/// </param>
/// <param name="y">
/// affine y co-ordinate
/// </param>
/// <param name="withCompression">
/// if true encode with point compression
/// </param>
constructor Create(const curve: IECCurve; const x, y: IECFieldElement;
withCompression: Boolean); overload;
deprecated
'Per-point compression property will be removed, see GetEncoded(boolean)';
constructor Create(const curve: IECCurve; const x, y: IECFieldElement;
const zs: TCryptoLibGenericArray<IECFieldElement>;
withCompression: Boolean); overload;
function Add(const b: IECPoint): IECPoint; override;
function Negate(): IECPoint; override;
function Twice(): IECPoint; override;
function TwicePlus(const b: IECPoint): IECPoint; override;
function GetYCoord: IECFieldElement; override;
property YCoord: IECFieldElement read GetYCoord;
end;
implementation
{ TSecT283K1Point }
function TSecT283K1Point.Add(const b: IECPoint): IECPoint;
var
LCurve: IECCurve;
X1, X2, L1, L2, Z1, Z2, U2, S2, U1, S1, A, LB, X3, L3, Z3, Y1, Y2, L, Y3, AU1,
AU2, ABZ2: IECFieldElement;
Z1IsOne, Z2IsOne: Boolean;
p: IECPoint;
begin
if ((IsInfinity)) then
begin
result := b;
Exit;
end;
if ((b.IsInfinity)) then
begin
result := Self as IECPoint;
Exit;
end;
LCurve := curve;
X1 := RawXCoord;
X2 := b.RawXCoord;
if (X1.IsZero) then
begin
if (X2.IsZero) then
begin
result := LCurve.Infinity;
Exit;
end;
result := b.Add(Self as IECPoint);
Exit;
end;
L1 := RawYCoord;
Z1 := RawZCoords[0];
L2 := b.RawYCoord;
Z2 := b.RawZCoords[0];
Z1IsOne := Z1.IsOne;
U2 := X2;
S2 := L2;
if (not(Z1IsOne)) then
begin
U2 := U2.Multiply(Z1);
S2 := S2.Multiply(Z1);
end;
Z2IsOne := Z2.IsOne;
U1 := X1;
S1 := L1;
if (not(Z2IsOne)) then
begin
U1 := U1.Multiply(Z2);
S1 := S1.Multiply(Z2);
end;
A := S1.Add(S2);
LB := U1.Add(U2);
if (LB.IsZero) then
begin
if (A.IsZero) then
begin
result := Twice();
Exit;
end;
result := LCurve.Infinity;
Exit;
end;
if (X2.IsZero) then
begin
// TODO This can probably be optimized quite a bit
p := Self.Normalize();
X1 := p.XCoord;
Y1 := p.YCoord;
Y2 := L2;
L := Y1.Add(Y2).Divide(X1);
X3 := L.Square().Add(L).Add(X1);
if (X3.IsZero) then
begin
result := TSecT283K1Point.Create(LCurve, X3, LCurve.b, IsCompressed);
Exit;
end;
Y3 := L.Multiply(X1.Add(X3)).Add(X3).Add(Y1);
L3 := Y3.Divide(X3).Add(X3);
Z3 := LCurve.FromBigInteger(TBigInteger.One);
end
else
begin
LB := LB.Square();
AU1 := A.Multiply(U1);
AU2 := A.Multiply(U2);
X3 := AU1.Multiply(AU2);
if (X3.IsZero) then
begin
result := TSecT283K1Point.Create(curve, X3, curve.b, IsCompressed);
Exit;
end;
ABZ2 := A.Multiply(LB);
if (not(Z2IsOne)) then
begin
ABZ2 := ABZ2.Multiply(Z2);
end;
L3 := AU2.Add(LB).SquarePlusProduct(ABZ2, L1.Add(Z1));
Z3 := ABZ2;
if (not(Z1IsOne)) then
begin
Z3 := Z3.Multiply(Z1);
end;
end;
result := TSecT283K1Point.Create(LCurve, X3, L3,
TCryptoLibGenericArray<IECFieldElement>.Create(Z3), IsCompressed);
end;
constructor TSecT283K1Point.Create(const curve: IECCurve;
const x, y: IECFieldElement);
begin
Create(curve, x, y, false);
end;
constructor TSecT283K1Point.Create(const curve: IECCurve;
const x, y: IECFieldElement;
const zs: TCryptoLibGenericArray<IECFieldElement>; withCompression: Boolean);
begin
Inherited Create(curve, x, y, zs, withCompression);
end;
constructor TSecT283K1Point.Create(const curve: IECCurve;
const x, y: IECFieldElement; withCompression: Boolean);
begin
Inherited Create(curve, x, y, withCompression);
if ((x = Nil) <> (y = Nil)) then
begin
raise EArgumentCryptoLibException.CreateRes(@SOneOfECFieldElementIsNil);
end;
end;
function TSecT283K1Point.Detach: IECPoint;
begin
result := TSecT283K1Point.Create(Nil, AffineXCoord, AffineYCoord);
end;
function TSecT283K1Point.GetCompressionYTilde: Boolean;
var
x, y: IECFieldElement;
begin
x := RawXCoord;
if (x.IsZero) then
begin
result := false;
Exit;
end;
y := RawYCoord;
// Y is actually Lambda (X + Y/X) here
result := y.TestBitZero() <> x.TestBitZero();
end;
function TSecT283K1Point.GetYCoord: IECFieldElement;
var
x, L, y, Z: IECFieldElement;
begin
x := RawXCoord;
L := RawYCoord;
if ((IsInfinity) or (x.IsZero)) then
begin
result := L;
Exit;
end;
// Y is actually Lambda (X + Y/X) here; convert to affine value on the fly
y := L.Add(x).Multiply(x);
Z := RawZCoords[0];
if (not(Z.IsOne)) then
begin
y := y.Divide(Z);
end;
result := y;
end;
function TSecT283K1Point.Negate: IECPoint;
var
x, L, Z: IECFieldElement;
begin
if (IsInfinity) then
begin
result := Self as IECPoint;
Exit;
end;
x := RawXCoord;
if (x.IsZero) then
begin
result := Self as IECPoint;
Exit;
end;
// L is actually Lambda (X + Y/X) here
L := RawYCoord;
Z := RawZCoords[0];
result := TSecT283K1Point.Create(curve, x, L.Add(Z),
TCryptoLibGenericArray<IECFieldElement>.Create(Z), IsCompressed);
end;
function TSecT283K1Point.Twice: IECPoint;
var
LCurve: IECCurve;
X1, L1, Z1, Z1Sq, T, X3, Z3, t1, t2, L3: IECFieldElement;
Z1IsOne: Boolean;
begin
if ((IsInfinity)) then
begin
result := Self as IECPoint;
Exit;
end;
LCurve := Self.curve;
X1 := RawXCoord;
if (X1.IsZero) then
begin
// A point with X == 0 is it's own Additive inverse
result := LCurve.Infinity;
Exit;
end;
L1 := RawYCoord;
Z1 := RawZCoords[0];
Z1IsOne := Z1.IsOne;
if Z1IsOne then
begin
Z1Sq := Z1;
end
else
begin
Z1Sq := Z1.Square();
end;
if (Z1IsOne) then
begin
T := L1.Square().Add(L1);
end
else
begin
T := L1.Add(Z1).Multiply(L1);
end;
if (T.IsZero) then
begin
result := TSecT283K1Point.Create(LCurve, T, LCurve.b, IsCompressed);
Exit;
end;
X3 := T.Square();
if Z1IsOne then
begin
Z3 := T;
end
else
begin
Z3 := T.Multiply(Z1Sq);
end;
t1 := L1.Add(X1).Square();
if Z1IsOne then
begin
t2 := Z1;
end
else
begin
t2 := Z1Sq.Square();
end;
L3 := t1.Add(T).Add(Z1Sq).Multiply(t1).Add(t2).Add(X3).Add(Z3);
result := TSecT283K1Point.Create(LCurve, X3, L3,
TCryptoLibGenericArray<IECFieldElement>.Create(Z3), IsCompressed);
end;
function TSecT283K1Point.TwicePlus(const b: IECPoint): IECPoint;
var
LCurve: IECCurve;
X1, X2, Z2, L1, Z1, L2, X1Sq, L1Sq, Z1Sq, L1Z1, T, L2plus1, A, X2Z1Sq, LB, X3,
Z3, L3: IECFieldElement;
begin
if ((IsInfinity)) then
begin
result := b;
Exit;
end;
if (b.IsInfinity) then
begin
result := Twice();
Exit;
end;
LCurve := Self.curve;
X1 := RawXCoord;
if (X1.IsZero) then
begin
// A point with X == 0 is it's own Additive inverse
result := b;
Exit;
end;
// NOTE: TwicePlus() only optimized for lambda-affine argument
X2 := b.RawXCoord;
Z2 := b.RawZCoords[0];
if ((X2.IsZero) or (not(Z2.IsOne))) then
begin
result := Twice().Add(b);
Exit;
end;
L1 := RawYCoord;
Z1 := RawZCoords[0];
L2 := b.RawYCoord;
X1Sq := X1.Square();
L1Sq := L1.Square();
Z1Sq := Z1.Square();
L1Z1 := L1.Multiply(Z1);
T := L1Sq.Add(L1Z1);
L2plus1 := L2.AddOne();
A := L2plus1.Multiply(Z1Sq).Add(L1Sq).MultiplyPlusProduct(T, X1Sq, Z1Sq);
X2Z1Sq := X2.Multiply(Z1Sq);
LB := X2Z1Sq.Add(T).Square();
if (LB.IsZero) then
begin
if (A.IsZero) then
begin
result := b.Twice();
Exit;
end;
result := LCurve.Infinity;
Exit;
end;
if (A.IsZero) then
begin
result := TSecT283K1Point.Create(LCurve, A, LCurve.b, IsCompressed);
Exit;
end;
X3 := A.Square().Multiply(X2Z1Sq);
Z3 := A.Multiply(LB).Multiply(Z1Sq);
L3 := A.Add(LB).Square().MultiplyPlusProduct(T, L2plus1, Z3);
result := TSecT283K1Point.Create(LCurve, X3, L3,
TCryptoLibGenericArray<IECFieldElement>.Create(Z3), IsCompressed);
end;
end.
|
unit Main;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls,
FMX.Layouts, FMX.Memo;
type
TFormMain = class(TForm)
ButtonListen: TButton;
StatusBar: TStatusBar;
LabelStatus: TLabel;
LabelResult: TLabel;
procedure ButtonListenClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
FormMain: TFormMain;
implementation
uses Androidapi.JNIBridge, Androidapi.JNI.Os, Androidapi.JNI.JavaTypes,
Androidapi.Helpers, FMX.Helpers.Android, android.speech;
{$R *.fmx}
function ErrorMessage(Error: Integer): string;
begin
case Error of
TJSpeechRecognizer_ERROR_AUDIO: Result := 'Audio recording error.';
TJSpeechRecognizer_ERROR_CLIENT: Result := 'Other client side errors.';
TJSpeechRecognizer_ERROR_INSUFFICIENT_PERMISSIONS: Result := 'Insufficient permissions.';
TJSpeechRecognizer_ERROR_NETWORK: Result := 'Other network related errors.';
TJSpeechRecognizer_ERROR_NETWORK_TIMEOUT: Result := 'Network operation timed out.';
TJSpeechRecognizer_ERROR_NO_MATCH: Result := 'No recognition result matched.';
TJSpeechRecognizer_ERROR_RECOGNIZER_BUSY: Result := 'RecognitionService busy.';
TJSpeechRecognizer_ERROR_SERVER: Result := 'Server sends error status.';
TJSpeechRecognizer_ERROR_SPEECH_TIMEOUT: Result := 'No speech input.';
else Result := 'Unknown error ' + IntToStr(Error);
end;
end;
type
TRecognitionListener = class(TJavaLocal, JRecognitionListener)
procedure onBeginningOfSpeech; cdecl;
procedure onBufferReceived(Buffer: TJavaArray<Byte>); cdecl;
procedure onEndOfSpeech; cdecl;
procedure onError(Error: Integer); cdecl;
procedure onEvent(EventType: Integer; Params: JBundle); cdecl;
procedure onPartialResults(PartialResults: JBundle); cdecl;
procedure onReadyForSpeech(Params: JBundle); cdecl;
procedure onResults(Results: JBundle); cdecl;
procedure onRmsChanged(RmsdB: Single); cdecl;
end;
procedure TRecognitionListener.onBeginningOfSpeech;
begin
FormMain.ButtonListen.Enabled := False;
FormMain.LabelStatus.Text := 'Beginning of speech';
end;
procedure TRecognitionListener.onBufferReceived(Buffer: TJavaArray<Byte>);
begin
end;
procedure TRecognitionListener.onEndOfSpeech;
begin
FormMain.LabelStatus.Text := 'End of speech';
FormMain.ButtonListen.Enabled := True;
end;
procedure TRecognitionListener.onError(Error: Integer);
begin
FormMain.LabelStatus.Text := 'Error: ' + ErrorMessage(Error);
end;
procedure TRecognitionListener.onEvent(EventType: Integer; Params: JBundle);
begin
end;
procedure TRecognitionListener.onPartialResults(PartialResults: JBundle);
begin
end;
procedure TRecognitionListener.onReadyForSpeech(Params: JBundle);
begin
FormMain.LabelStatus.Text := 'Ready for speech';
end;
procedure TRecognitionListener.onResults(Results: JBundle);
var
ArrayList: JArrayList;
I: Integer;
Text: string;
begin
Text := '';
ArrayList := Results.getStringArrayList(StringToJString(TJSpeechRecognizer_RESULTS_RECOGNITION));
for I := 0 to ArrayList.size - 1 do
Text := Text + JStringToString(ArrayList.get(I).toString) + sLineBreak;
FormMain.LabelResult.Text := Text;
FormMain.LabelStatus.Text := 'Results';
end;
procedure TRecognitionListener.onRmsChanged(RmsdB: Single);
begin
end;
var
SpeechRecognizer: JSpeechRecognizer;
RecognitionListener: JRecognitionListener;
procedure TFormMain.ButtonListenClick(Sender: TObject);
begin
FormMain.LabelResult.Text := '';
FormMain.LabelStatus.Text := '';
if not TJSpeechRecognizer.JavaClass.isRecognitionAvailable(SharedActivityContext) then
begin
ShowMessage('Speech recognition is not available');
Exit;
end;
CallInUiThread(
procedure
begin
if SpeechRecognizer = nil then
begin
SpeechRecognizer := TJSpeechRecognizer.JavaClass.createSpeechRecognizer(SharedActivityContext);
RecognitionListener := TRecognitionListener.Create;
SpeechRecognizer.setRecognitionListener(RecognitionListener);
end;
SpeechRecognizer.startListening(TJRecognizerIntent.JavaClass.getVoiceDetailsIntent(SharedActivityContext));
end);
end;
end.
|
{********************************************************************}
{ TPARAMTREEVIEW component }
{ for Delphi & C++Builder }
{ }
{ Written by }
{ TMS Software }
{ Copyright © 2000-2012 }
{ Email : info@tmssoftware.com }
{ Web : http://www.tmssoftware.com }
{********************************************************************}
unit paramtreeviewregde;
{$I TMSDEFS.INC}
interface
uses
ParamTreeview, Classes, paramsde, ComCtrls,
{$IFDEF DELPHI6_LVL}
DesignIntf, DesignEditors
{$ELSE}
DsgnIntf
{$ENDIF}
;
procedure Register;
implementation
procedure Register;
begin
RegisterPropertyEditor(TypeInfo(TTreeNodes), TParamTreeView, 'Items', TParamNodesProperty);
RegisterComponentEditor(TParamTreeView, TParamListDefaultEditor);
end;
end.
|
unit caFromClause;
// Модуль: "w:\common\components\rtl\Garant\ComboAccess\caFromClause.pas"
// Стереотип: "SimpleClass"
// Элемент модели: "TcaFromClause" MUID: (574D5A9900B6)
{$Include w:\common\components\rtl\Garant\ComboAccess\caDefine.inc}
interface
{$If Defined(UsePostgres) AND Defined(TestComboAccess)}
uses
l3IntfUses
, l3ProtoObject
, daInterfaces
, daTypes
;
type
TcaFromClause = class(Tl3ProtoObject, IdaFromClause, IdaJoin, IdaComboAccessFromClauseHelper)
private
f_HTClause: IdaFromClause;
f_PGClause: IdaFromClause;
f_Factory: IdaTableQueryFactory;
protected
function BuildSQLValue(const aHelper: IdaParamListHelper): AnsiString;
function HasTable(const aTable: IdaTableDescription): Boolean;
function FindTable(const aTableAlias: AnsiString): IdaFromTable;
function Get_Left: IdaFromClause;
function Get_Right: IdaFromClause;
function Get_Kind: TdaJoinKind;
function Get_Condition: IdaCondition;
function SetCondition(const aCondition: IdaCondition): IdaFromClause;
function Join(const aRight: IdaFromClause;
aKind: TdaJoinKind): IdaJoin;
function IsRelationsConditionsValid: Boolean;
function Get_HTClause: IdaFromClause;
function Get_PGClause: IdaFromClause;
procedure Cleanup; override;
{* Функция очистки полей объекта. }
public
constructor Create(const aFactory: IdaTableQueryFactory;
const aHTClause: IdaFromClause;
const aPGClause: IdaFromClause); reintroduce;
class function Make(const aFactory: IdaTableQueryFactory;
const aHTClause: IdaFromClause;
const aPGClause: IdaFromClause): IdaJoin; reintroduce;
procedure IterateTablesF(anAction: daFromClauseIterator_IterateTablesF_Action);
procedure IterateRelationConditionsF(anAction: daFromClauseIterator_IterateRelationConditionsF_Action);
end;//TcaFromClause
{$IfEnd} // Defined(UsePostgres) AND Defined(TestComboAccess)
implementation
{$If Defined(UsePostgres) AND Defined(TestComboAccess)}
uses
l3ImplUses
, SysUtils
, l3Base
//#UC START# *574D5A9900B6impl_uses*
//#UC END# *574D5A9900B6impl_uses*
;
constructor TcaFromClause.Create(const aFactory: IdaTableQueryFactory;
const aHTClause: IdaFromClause;
const aPGClause: IdaFromClause);
//#UC START# *574D5AFE0110_574D5A9900B6_var*
//#UC END# *574D5AFE0110_574D5A9900B6_var*
begin
//#UC START# *574D5AFE0110_574D5A9900B6_impl*
inherited Create;
f_HTClause := aHTCLause;
f_PGClause := aPGClause;
f_Factory := aFactory;
//#UC END# *574D5AFE0110_574D5A9900B6_impl*
end;//TcaFromClause.Create
class function TcaFromClause.Make(const aFactory: IdaTableQueryFactory;
const aHTClause: IdaFromClause;
const aPGClause: IdaFromClause): IdaJoin;
var
l_Inst : TcaFromClause;
begin
l_Inst := Create(aFactory, aHTClause, aPGClause);
try
Result := l_Inst;
finally
l_Inst.Free;
end;//try..finally
end;//TcaFromClause.Make
function TcaFromClause.BuildSQLValue(const aHelper: IdaParamListHelper): AnsiString;
//#UC START# *5608E5F20118_574D5A9900B6_var*
//#UC END# *5608E5F20118_574D5A9900B6_var*
begin
//#UC START# *5608E5F20118_574D5A9900B6_impl*
Result := f_HTClause.BuildSQLValue(aHelper);
Assert(Result = f_PGClause.BuildSQLValue(aHelper));
//#UC END# *5608E5F20118_574D5A9900B6_impl*
end;//TcaFromClause.BuildSQLValue
function TcaFromClause.HasTable(const aTable: IdaTableDescription): Boolean;
//#UC START# *57442BFD03BE_574D5A9900B6_var*
//#UC END# *57442BFD03BE_574D5A9900B6_var*
begin
//#UC START# *57442BFD03BE_574D5A9900B6_impl*
Result := f_HTClause.HasTable(aTable);
Assert(Result = f_PGClause.HasTable(aTable));
//#UC END# *57442BFD03BE_574D5A9900B6_impl*
end;//TcaFromClause.HasTable
function TcaFromClause.FindTable(const aTableAlias: AnsiString): IdaFromTable;
//#UC START# *5744366C003B_574D5A9900B6_var*
//#UC END# *5744366C003B_574D5A9900B6_var*
begin
//#UC START# *5744366C003B_574D5A9900B6_impl*
Result := f_HTClause.FindTable(aTableAlias);
Assert(Result = f_PGClause.FindTable(aTableAlias));
//#UC END# *5744366C003B_574D5A9900B6_impl*
end;//TcaFromClause.FindTable
procedure TcaFromClause.IterateTablesF(anAction: daFromClauseIterator_IterateTablesF_Action);
//#UC START# *574443A401BE_574D5A9900B6_var*
//#UC END# *574443A401BE_574D5A9900B6_var*
begin
//#UC START# *574443A401BE_574D5A9900B6_impl*
f_HTClause.IterateTablesF(anAction);
//!! !!! Needs to be implemented !!! Что с PGClause;
//#UC END# *574443A401BE_574D5A9900B6_impl*
end;//TcaFromClause.IterateTablesF
function TcaFromClause.Get_Left: IdaFromClause;
//#UC START# *57456F6B01D2_574D5A9900B6get_var*
var
l_HTJoin: IdaJoin;
l_PGJoin: IdaJoin;
//#UC END# *57456F6B01D2_574D5A9900B6get_var*
begin
//#UC START# *57456F6B01D2_574D5A9900B6get_impl*
if Supports(f_HTClause, IdaJoin, l_HTJoin) and Supports(f_PGClause, IdaJoin, l_PGJoin) then
Result := TcaFromClause.Make(f_Factory, l_HTJoin.Left, l_PGJoin.Left) as IdaFromClause
else
Result := nil;
//#UC END# *57456F6B01D2_574D5A9900B6get_impl*
end;//TcaFromClause.Get_Left
function TcaFromClause.Get_Right: IdaFromClause;
//#UC START# *57456F800124_574D5A9900B6get_var*
var
l_HTJoin: IdaJoin;
l_PGJoin: IdaJoin;
//#UC END# *57456F800124_574D5A9900B6get_var*
begin
//#UC START# *57456F800124_574D5A9900B6get_impl*
if Supports(f_HTClause, IdaJoin, l_HTJoin) and Supports(f_PGClause, IdaJoin, l_PGJoin) then
Result := TcaFromClause.Make(f_Factory, l_HTJoin.Right, l_PGJoin.Right) as IdaFromClause
else
Result := nil;
//#UC END# *57456F800124_574D5A9900B6get_impl*
end;//TcaFromClause.Get_Right
function TcaFromClause.Get_Kind: TdaJoinKind;
//#UC START# *5745700A0180_574D5A9900B6get_var*
var
l_HTJoin: IdaJoin;
l_PGJoin: IdaJoin;
//#UC END# *5745700A0180_574D5A9900B6get_var*
begin
//#UC START# *5745700A0180_574D5A9900B6get_impl*
if Supports(f_HTClause, IdaJoin, l_HTJoin) and Supports(f_PGClause, IdaJoin, l_PGJoin) then
begin
Result := l_HTJoin.Kind;
Assert(Result = l_PGJoin.Kind);
end
else
Result := da_jkInner;
//#UC END# *5745700A0180_574D5A9900B6get_impl*
end;//TcaFromClause.Get_Kind
function TcaFromClause.Get_Condition: IdaCondition;
//#UC START# *5745702503A6_574D5A9900B6get_var*
var
l_HTJoin: IdaJoin;
//#UC END# *5745702503A6_574D5A9900B6get_var*
begin
//#UC START# *5745702503A6_574D5A9900B6get_impl*
if Supports(f_HTClause, IdaJoin, l_HTJoin) then
Result := l_HTJoin.Condition
else
Result := nil;
//#UC END# *5745702503A6_574D5A9900B6get_impl*
end;//TcaFromClause.Get_Condition
function TcaFromClause.SetCondition(const aCondition: IdaCondition): IdaFromClause;
//#UC START# *574570520193_574D5A9900B6_var*
var
l_HTJoin: IdaJoin;
l_PGJoin: IdaJoin;
//#UC END# *574570520193_574D5A9900B6_var*
begin
//#UC START# *574570520193_574D5A9900B6_impl*
if Supports(f_HTClause, IdaJoin, l_HTJoin) and Supports(f_PGClause, IdaJoin, l_PGJoin) then
begin
l_HTJoin.SetCondition(aCondition);
l_PGJoin.SetCondition(aCondition);
Result := Self;
end;
//#UC END# *574570520193_574D5A9900B6_impl*
end;//TcaFromClause.SetCondition
function TcaFromClause.Join(const aRight: IdaFromClause;
aKind: TdaJoinKind): IdaJoin;
//#UC START# *574570790329_574D5A9900B6_var*
//#UC END# *574570790329_574D5A9900B6_var*
begin
//#UC START# *574570790329_574D5A9900B6_impl*
Result := f_Factory.MakeJoin(Self, aRight, aKind);
//#UC END# *574570790329_574D5A9900B6_impl*
end;//TcaFromClause.Join
function TcaFromClause.IsRelationsConditionsValid: Boolean;
//#UC START# *57480BE20140_574D5A9900B6_var*
//#UC END# *57480BE20140_574D5A9900B6_var*
begin
//#UC START# *57480BE20140_574D5A9900B6_impl*
Result := f_HTClause.IsRelationsConditionsValid;
Assert(Result = f_PGClause.IsRelationsConditionsValid);
//#UC END# *57480BE20140_574D5A9900B6_impl*
end;//TcaFromClause.IsRelationsConditionsValid
procedure TcaFromClause.IterateRelationConditionsF(anAction: daFromClauseIterator_IterateRelationConditionsF_Action);
//#UC START# *574824090133_574D5A9900B6_var*
//#UC END# *574824090133_574D5A9900B6_var*
begin
//#UC START# *574824090133_574D5A9900B6_impl*
f_HTClause.IterateRelationConditionsF(anAction);
//!! !!! Needs to be implemented !!! Что с PGClause;
//#UC END# *574824090133_574D5A9900B6_impl*
end;//TcaFromClause.IterateRelationConditionsF
function TcaFromClause.Get_HTClause: IdaFromClause;
//#UC START# *574D5A4C0298_574D5A9900B6get_var*
//#UC END# *574D5A4C0298_574D5A9900B6get_var*
begin
//#UC START# *574D5A4C0298_574D5A9900B6get_impl*
Result := f_HTClause;
//#UC END# *574D5A4C0298_574D5A9900B6get_impl*
end;//TcaFromClause.Get_HTClause
function TcaFromClause.Get_PGClause: IdaFromClause;
//#UC START# *574D5A61018D_574D5A9900B6get_var*
//#UC END# *574D5A61018D_574D5A9900B6get_var*
begin
//#UC START# *574D5A61018D_574D5A9900B6get_impl*
Result := f_PGClause;
//#UC END# *574D5A61018D_574D5A9900B6get_impl*
end;//TcaFromClause.Get_PGClause
procedure TcaFromClause.Cleanup;
{* Функция очистки полей объекта. }
//#UC START# *479731C50290_574D5A9900B6_var*
//#UC END# *479731C50290_574D5A9900B6_var*
begin
//#UC START# *479731C50290_574D5A9900B6_impl*
f_HTClause := nil;
f_PGClause := nil;
f_Factory := nil;;
inherited;
//#UC END# *479731C50290_574D5A9900B6_impl*
end;//TcaFromClause.Cleanup
{$IfEnd} // Defined(UsePostgres) AND Defined(TestComboAccess)
end.
|
ALGORITHME: Jeu_de_l'oie
//BUT: le jeu de l'oie
//Entree: la validation pour continuer
//Sorties: Le jeu sous forme d'entier
CONST :
départ <- 0:ENTIER
fin <- 66:ENTIER
double <- 9:ENTIER
pas de double <- 63:ENTIER
mort <- 58:ENTIER
min <- 2:ENTIER
max <- 12:ENTIER
VAR : dés, place :ENTIER
DEBUT
Ecrire "Appuyez sur ENTRER pour commencer le jeu de l'oie"
Lire
dés <- 0
place <- 0
Ecrire "Vous commencez à la case départ",place
REPETER
Ecrire "ENTRER pour continuer"
Lire
Ecrire "lance les deux dés"
dés <- aleatoire (min,max)
Ecrire dés "obtenu"
place <- (dés+place)
Ecrire "Vous allez à la case", place
SI(place=mort) et (place <> pas double)ALORS
place <- 0
Ecrire "Votre jet est doublé, vous allez donc à la case", place
FINSI
SI (place=mort)ALORS
place <- 0
Ecrire "Vous etes sur la case tete de mort"
Ecrire "Retour à la case depart"
FINSI
SI (place>fin)ALORS
place <-(place-(place-fin))
Ecrire "Vous allez à la case",place
FINSI
SI (place Mod double=0) et (place <> pas double)ALORS
place <- dos+place
Ecrire "Votre jet est doublé, donc vous allez à la case",place
FINSI
SI (place=mort) ALORS
place <- 0
Ecrire "Vous etes sur la case tete de mort"
Ecrire "retour à la case départ"
FINSI
SI (place>fin) ALORS
place <- (place-(place-fin))
Ecrire "Vous allez à la case",place
FINSI
Jusqu'à (place=fin)
Ecrire "Vous avez gagné"
FIN |
unit MultiMM;
// $Id: MultiMM.pas,v 1.2 2001/02/01 14:21:20 law Exp $
// $Log: MultiMM.pas,v $
// Revision 1.2 2001/02/01 14:21:20 law
// - добавлены директивы Id и Log.
//
interface
uses HPMM;
var
PrevMemoryManager:TMemoryManager;
MemoryManager:TMemoryManager;
type
TMainMemManager=class(TMemManager)
public
procedure Transfer(var TransferArray:TTransferArray);
constructor Create;
destructor Destroy; override;
end;
TThreadMemManager=class(TBlockManager)
private
IsUsed:boolean;
procedure EmptyPools;
procedure Transfer(var TransferArray: TTransferArray);
protected
function IsAvailable(sizeIndex: integer): Boolean; override;
procedure Allocate(Size:integer); override;
procedure MakeAvailable(SizeIndex:integer; var count:integer); override;
procedure ReturnToPool(Block: PFreeBlock); override;
procedure FreeManager;
public
constructor Create;
destructor Destroy; override;
end;
var
MainManager:TMainMemManager;
implementation
type
BOOL = LongBool;
TRTLCriticalSection = record
DebugInfo: Pointer;
LockCount: Longint;
RecursionCount: Longint;
OwningThread: Integer;
LockSemaphore: Integer;
Reserved: DWORD;
end;
const
kernel = 'kernel32.dll';
PAGE_NOACCESS = 1;
PAGE_READWRITE = 4;
type THandle = Integer;
function FlushInstructionCache(hProcess: THandle; const lpBaseAddress:
Pointer; dwSize: DWORD): BOOL; stdcall;
external kernel name 'FlushInstructionCache';
function GetCurrentProcess: THandle; stdcall;
external kernel name 'GetCurrentProcess';
function VirtualProtect(lpAddress:pointer; dwSize, flNewProtect: DWORD;
var lpflOldProtect:DWord):BOOL; stdcall;
external kernel name 'VirtualProtect';
procedure InitializeCriticalSection(var lpCriticalSection: TRTLCriticalSection); stdcall;
external kernel name 'InitializeCriticalSection';
procedure EnterCriticalSection(var lpCriticalSection: TRTLCriticalSection); stdcall;
external kernel name 'EnterCriticalSection';
procedure LeaveCriticalSection(var lpCriticalSection: TRTLCriticalSection); stdcall;
external kernel name 'LeaveCriticalSection';
procedure DeleteCriticalSection(var lpCriticalSection: TRTLCriticalSection); stdcall;
external kernel name 'DeleteCriticalSection';
procedure ExitThread(ExitCode: Integer); stdcall;
external kernel name 'ExitThread';
var
heapLock : TRTLCriticalSection;
ThreadLock : TRTLCriticalSection;
{ TThreadMemManager }
function TThreadMemManager.IsAvailable(sizeIndex: integer): Boolean;
begin
result:=(BlockPools[SizeIndex].Count>0);
if not result then
if MainManager.BlockPools[SizeIndex].Count>0 then // read only
begin
result:=true;
Allocate(1 shl SizeIndex);
end;
end;
procedure TThreadMemManager.ReturnToPool(Block:PFreeBlock);
var Pool:PBlockPool;
begin
Inherited ReturnToPool(Block);
Pool:=@BlockPools[Block.SizeIndex];
if Pool.Count>Pool.HiLimit then
Allocate(0);
end;
constructor TThreadMemManager.Create;
begin
inherited Create;
IsUsed:=false;
end;
procedure TThreadMemManager.Transfer(var TransferArray: TTransferArray);
begin
try
EnterCriticalSection(heapLock);
MainManager.Transfer(TransferArray);
finally
LeaveCriticalSection(heapLock);
end;
end;
procedure TThreadMemManager.Allocate(Size:integer);
var
j:integer;
TransferArray:TTransferArray;
Pool:PBlockPool;
SizeIndex:integer;
begin
SizeIndex:=RoundUpAlign(Size);
for j:=MinTableIndex to MaxTableIndex do
begin
Pool:=@BlockPools[j];
if Pool.Count>Pool.MaxCount then
TransferArray[j].Count:=Pool.MaxCount-Pool.Count
else
TransferArray[j].Count:=0;
end;
GiveTransfer(TransferArray);
for j:=MinTableIndex to MaxTableIndex do
begin
Pool:=@BlockPools[j];
if Pool.Count<Pool.MinCount then
TransferArray[j].Count:=Pool.Count-Pool.MinCount;
end;
if TransferArray[SizeIndex].Count=0 then
dec(TransferArray[SizeIndex].Count);
Transfer(TransferArray);
TakeTransfer(TransferArray);
end;
procedure TThreadMemManager.FreeManager;
begin
IsUsed:=false;
end;
procedure TThreadMemManager.EmptyPools;
var
j:integer;
TransferArray:TTransferArray;
begin
for j:=MinTableIndex to MaxTableIndex do
TransferArray[j].Count:=-BlockPools[j].Count;
GiveTransfer(TransferArray);
Transfer(TransferArray);
end;
procedure TThreadMemManager.MakeAvailable(SizeIndex: integer; var count: integer);
begin
Count:=BlockPools[SizeIndex].Count;
end;
destructor TThreadMemManager.Destroy;
begin
EmptyPools;
inherited Destroy;
end;
{ TMainMemManager }
type
PMemManagerArray=^TMemManagerArray;
TMemManagerArray=array[0..(maxint div Sizeof(TThreadMemManager))-1] of TThreadMemManager;
var
MemManagerList:PMemManagerArray;
ManagerCapacity:integer;
ManagerCount:integer;
threadvar MemManagerIndex:integer;
constructor TMainMemManager.Create;
begin
inherited Create;
ManagerCapacity:=100;
MemManagerList:=GetMem(ManagerCapacity*SizeOf(TMemManager));
ManagerCount:=0;
end;
destructor TMainMemManager.Destroy;
var i:integer;
begin
for i:=1 to ManagerCount do
MemManagerList[i].Free;
FreeMem(MemManagerList);
inherited Destroy;
end;
procedure TMainMemManager.Transfer(var TransferArray: TTransferArray);
begin
TakeTransfer(TransferArray);
GiveTransfer(TransferArray);
end;
{ }
function InitMemManagerIndex:integer;
begin
try
EnterCriticalSection(ThreadLock);
Result:=1; // Leave zero blank as uninitialized flag
while (Result<=ManagerCount) and TThreadMemManager(MemManagerList[Result]).IsUsed do
inc(Result);
if (Result>ManagerCount) then
begin
inc(ManagerCount);
if Result=ManagerCapacity then
begin
MainManager.ReAllocMem(MemManagerList,ManagerCapacity*2*Sizeof(TMemManager));
inc(ManagerCapacity);
end;
end
finally
LeaveCriticalSection(ThreadLock);
end;
if Result=ManagerCount then
MemManagerList[Result]:=TThreadMemManager.Create;
TThreadMemManager(MemManagerList[Result]).IsUsed:=true;
end;
function GetMem(MinSize:integer):Pointer;
var Index:integer;
begin
if IsMultiThread then
begin
Index:=MemManagerIndex;
if Index=0 then
begin
Index:=InitMemManagerIndex;
MemManagerIndex:=Index;
end;
Result:=MemManagerList[Index].GetMem(MinSize);
end
else
Result:=MainManager.GetMem(MinSize);
end;
function FreeMem(addr:pointer):integer;
var Index:integer;
begin
if IsMultiThread then
begin
Index:=MemManagerIndex;
if Index=0 then
begin
Index:=InitMemManagerIndex;
MemManagerIndex:=Index;
end;
Result:=MemManagerList[Index].FreeMem(addr);
end
else
Result:=MainManager.FreeMem(addr);
if Result<>0 then
result:=PrevMemoryManager.FreeMem(addr);
end;
function ReAllocMem(addr:pointer; Size:integer):Pointer;
var Index:integer;
begin
if IsMultiThread then
begin
Index:=MemManagerIndex;
if Index=0 then
begin
Index:=InitMemManagerIndex;
MemManagerIndex:=Index;
end;
Result:=MemManagerList[Index].ReAllocMem(addr,Size);
end
else
Result:=MainManager.ReAllocMem(addr,Size);
if not assigned(Result) then
begin
Result:=GetMem(size);
move(addr^,Result^,size);
if PrevMemoryManager.FreeMem(addr)<>0 then
begin
FreeMem(Result);
Result:=nil;
end;
end;
end;
procedure NewEndThread(exitCode:integer); register // ensure that calling convension matches EndThread
// Free up Manager assigned to thread
var
index:integer;
begin
index:=MemManagerIndex;
if index>0 then
TThreadMemManager(MemManagerList[Index]).IsUsed:=false;
// code of original EndThread;
ExitThread(exitCode);
end;
type
PJump=^TJump;
TJump=packed record
OpCode:byte;
Distance:integer;
end;
var
OldCode:TJump;
NewCode:TJump=(OpCode:$E9; Distance:0);
procedure PatchEndThread;
// redirect calls to System.EndThread to NewNewThread
var
EndThreadAddr:PJump;
OldProtect,Protect:DWord;
begin
EndThreadAddr:=Pointer(@EndThread);
NewCode.Distance:=Integer(@NewEndThread)-(Integer(@EndThread)+5);
VirtualProtect(EndThreadAddr,5,PAGE_READWRITE,OldProtect);
OldCode:=EndThreadAddr^;
EndThreadAddr^:=NewCode;
VirtualProtect(EndThreadAddr,5,OldProtect,Protect);
FlushInstructionCache(GetCurrentProcess, EndThreadAddr,5);
end;
procedure UnPatchEndThread;
var
EndThreadAddr:PJump;
OldProtect,Protect:DWord;
begin
EndThreadAddr:=Pointer(@EndThread);
NewCode.Distance:=Integer(@NewEndThread)-(Integer(@EndThread)+5);
VirtualProtect(EndThreadAddr,5,PAGE_READWRITE,OldProtect);
EndThreadAddr^:=OldCode;
VirtualProtect(EndThreadAddr,5,OldProtect,Protect);
FlushInstructionCache(GetCurrentProcess, EndThreadAddr,5);
end;
initialization
InitializeCriticalSection(HeapLock);
InitializeCriticalSection(ThreadLock);
MainManager:=TMainMemManager.Create;
GetMemoryManager(PrevMemoryManager);
PatchEndThread;
MemoryManager.GetMem:=GetMem;
MemoryManager.ReAllocMem:=ReAllocMem;
MemoryManager.FreeMem:=FreeMem;
SetMemoryManager(MemoryManager);
finalization
SetMemoryManager(PrevMemoryManager);
MainManager.Free;
// Block Manager
DeleteCriticalSection(HeapLock);
DeleteCriticalSection(ThreadLock);
UnPatchEndThread; // just to be tidy
end.
|
unit DW.Androidapi.JNI.FileProvider;
{*******************************************************}
{ }
{ Kastri Free }
{ }
{ DelphiWorlds Cross-Platform Library }
{ }
{*******************************************************}
//{$I DW.GlobalDefines.inc}
interface
uses
Androidapi.JNIBridge, Androidapi.JNI.GraphicsContentViewText, Androidapi.JNI.JavaTypes, Androidapi.JNI.Net, Androidapi.JNI.Os;
type
JFileProvider = interface;
JFileProviderClass = interface(JContentProviderClass)
['{33A87969-5731-4791-90F6-3AD22F2BB822}']
{class} function getUriForFile(context: JContext; authority: JString; _file: JFile): Jnet_Uri; cdecl;
{class} function init: JFileProvider; cdecl;
end;
[JavaSignature('android/support/v4/content/FileProvider')]
JFileProvider = interface(JContentProvider)
['{12F5DD38-A3CE-4D2E-9F68-24933C9D221B}']
procedure attachInfo(context: JContext; info: JProviderInfo); cdecl;
function delete(uri: Jnet_Uri; selection: JString; selectionArgs: TJavaObjectArray<JString>): Integer; cdecl;
function getType(uri: Jnet_Uri): JString; cdecl;
function insert(uri: Jnet_Uri; values: JContentValues): Jnet_Uri; cdecl;
function onCreate: Boolean; cdecl;
function openFile(uri: Jnet_Uri; mode: JString): JParcelFileDescriptor; cdecl;
function query(uri: Jnet_Uri; projection: TJavaObjectArray<JString>; selection: JString; selectionArgs: TJavaObjectArray<JString>;
sortOrder: JString): JCursor; cdecl;
function update(uri: Jnet_Uri; values: JContentValues; selection: JString; selectionArgs: TJavaObjectArray<JString>): Integer; cdecl;
end;
TJFileProvider = class(TJavaGenericImport<JFileProviderClass, JFileProvider>) end;
implementation
end. |
unit frm_ListadoResponsables;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, db, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
Buttons, DBGrids
,dmGeneral
;
type
{ TfrmListadoResponsables }
TfrmListadoResponsables = class(TForm)
btnSalir: TBitBtn;
btnAgregar: TBitBtn;
btnModificar: TBitBtn;
btnEliminar: TBitBtn;
DS_Responsables: TDatasource;
DBGrid1: TDBGrid;
Panel1: TPanel;
procedure btnAgregarClick(Sender: TObject);
procedure btnEliminarClick(Sender: TObject);
procedure btnModificarClick(Sender: TObject);
procedure btnSalirClick(Sender: TObject);
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
procedure FormCreate(Sender: TObject);
private
function getApyNomResponsableSeleccionado: string;
function getIdResponsableSeleccionado: GUID_ID;
procedure PantallaEdicion (idEdicion: GUID_ID);
public
property idResponsableSeleccionado: GUID_ID read getIdResponsableSeleccionado;
property ApyNomResponsableSelecciondo: string read getApyNomResponsableSeleccionado;
end;
var
frmListadoResponsables: TfrmListadoResponsables;
implementation
{$R *.lfm}
uses
dmresponsables
,frm_responsableae
;
{ TfrmListadoResponsables }
procedure TfrmListadoResponsables.FormClose(Sender: TObject;
var CloseAction: TCloseAction);
begin
// if NOT (fsModal in (sender as TForm).FormState) then //Me fijo si se abrio como modal para no destruirlo
// CloseAction:= caFree;
end;
procedure TfrmListadoResponsables.btnSalirClick(Sender: TObject);
begin
//Dependiendo de cómo lo abro, lo cierro
// if (fsModal in self.FormState) then
ModalResult:= mrOK
// else
// close;
end;
procedure TfrmListadoResponsables.FormCreate(Sender: TObject);
begin
DM_Responsables.ObtenerTodosLosResponsables;
end;
function TfrmListadoResponsables.getApyNomResponsableSeleccionado: string;
begin
with DS_Responsables.DataSet do
begin
if RecordCount > 0 then
Result:= FieldByName('cApellidos').asString + FieldByName('cNombres').asString
else
Result:= EmptyStr;
end;
end;
function TfrmListadoResponsables.getIdResponsableSeleccionado: GUID_ID;
begin
with DS_Responsables.DataSet do
begin
if RecordCount > 0 then
Result:= FieldByName('idResponsable').asString
else
Result:= GUIDNULO;
end;
end;
(*******************************************************************************
*** Administra la pantalla de Modificación/Ingreso de un Responsable
********************************************************************************)
procedure TfrmListadoResponsables.PantallaEdicion(idEdicion: GUID_ID);
var
pantalla: TfrmResponsableae;
begin
pantalla:= TfrmResponsableae.Create(self);
try
pantalla.idResponsable:= idEdicion;
pantalla.ShowModal;
DM_Responsables.ObtenerTodosLosResponsables;
finally
pantalla.Free;
end;
end;
procedure TfrmListadoResponsables.btnAgregarClick(Sender: TObject);
begin
PantallaEdicion(GUIDNULO);
end;
procedure TfrmListadoResponsables.btnModificarClick(Sender: TObject);
begin
PantallaEdicion(DM_Responsables.SeleccionTodosLosResponsables);
end;
(*******************************************************************************
*** Borro un responsable
********************************************************************************)
procedure TfrmListadoResponsables.btnEliminarClick(Sender: TObject);
begin
if (MessageDlg ('ATENCION', 'Borro el Responsable seleccionado?', mtConfirmation, [mbYes, mbNo],0 ) = mrYes) then
begin
DM_Responsables.Borrar(DM_Responsables.SeleccionTodosLosResponsables);
DM_Responsables.ObtenerTodosLosResponsables;
end;
end;
end.
|
{*_* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Program: TNEMULVT.PAS
Description: Delphi component combining both TnCnx and EmulVT components.
Hence it does ANSI emulation using TCP/IP telnet protocol.
Author: François PIETTE
Creation: May, 1996
Version: 2.14
EMail: http://www.overbyte.be francois.piette@overbyte.be
Support: Use the mailing list twsocket@elists.org
Follow "support" link at http://www.overbyte.be for subscription.
Legal issues: Copyright (C) 1996-2006 by François PIETTE
Rue de Grady 24, 4053 Embourg, Belgium. Fax: +32-4-365.74.56
<francois.piette@overbyte.be>
This software is provided 'as-is', without any express or
implied warranty. In no event will the author be held liable
for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it
and redistribute it freely, subject to the following
restrictions:
1. The origin of this software must not be misrepresented,
you must not claim that you wrote the original software.
If you use this software in a product, an acknowledgment
in the product documentation would be appreciated but is
not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
4. You must register this software by sending a picture postcard
to the author. Use a nice stamp and mention your name, street
address, EMail address and any comment you like to say.
Updates:
Jul 22, 1997 Revised Connect method to be callable from FormCreate event
Adapted to Delphi 3
Sep 05, 1997 TnCnx made public, Minor change to method visibility
Added OnTermType and OnDataAvailable events.
Sep 23, 1997 V202. Added local echo support (incomplete because we should ask
the remote host not to echo characters. Will implement later)
Added TnEmultVTVersion
Sep 24, 1997 V2.03 Complete local echo support.
Sep 25, 1997 V2.04 Port to C++Builder
Feb 19, 1998 V2.05 Replaced private section by protected.
Added TriggerDataAvailable virtual function.
Dec 21, 1998 V2.06 Added fixes from Steve Endicott.
Mar 01, 1999 V2.07 Added conditional compile for BCB4. Thanks to James
Legg <jlegg@iname.com>.
Mar 14, 1999 V2.08 Added OnKeyDown event to allow key trapping.
Ignore any exception when sending fct keys.
Aug 15, 1999 V2.09 Move KeyPress procedure to public section for BCB4 compat.
Aug 20, 1999 V2.10 Added compile time options. Revised for BCB4.
Sep 25, 1999 V2.11 Corrected GetSelTextBuf so that lines are returned in
corrected order (they where returned in reverse order).
Thanks to Laurent Navarro <r2363c@email.sps.mot.com> for finding
this bug and fixing it.
Jan 12, 2002 V2.12 Replaced TnCnx public member by TnConn property to avoid
conflit with unit named TnCnx. This will require change in your
own code if you used this property. Added a notification procedure
to remove FTnCnx if component is externally destroyed. Added code
to check if we still have the component with us.
Oct 23, 2002 V2.13 Changed Buffer arg in OnDataAvailable to Pointer instead
of PChar to avoid Delphi 7 messing everything with AnsiChar.
May 31, 2004 V2.14 Used ICSDEFS.INC, removed unused unit
Mar 26, 2006 V2.15 Fixed TnCnxSessionConnected where global Error variable was
used instead of local argument.
Renamed Erc argument to ErrorCode.
Mar 26, 2005 V6.00 New version 6 started from V5
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
unit OverbyteIcsTnEmulVT;
{$R-} { Range Check off }
{$B-} { Enable partial boolean evaluation }
{$T-} { Untyped pointers }
{$X+} { Enable extended syntax }
{$I OverbyteIcsDefs.inc}
{$IFDEF DELPHI6_UP}
{$WARN SYMBOL_PLATFORM OFF}
{$WARN SYMBOL_LIBRARY OFF}
{$WARN SYMBOL_DEPRECATED OFF}
{$ENDIF}
{$IFNDEF VER80} { Not for Delphi 1 }
{$H+} { Use long strings }
{$J+} { Allow typed constant to be modified }
{$ENDIF}
{$IFDEF BCB3_UP}
{$ObjExportAll On}
{$ENDIF}
interface
uses
Messages,
{$IFDEF USEWINDOWS}
Windows,
{$ELSE}
WinTypes, WinProcs,
{$ENDIF}
SysUtils, Classes, Graphics, Controls, IniFiles, Forms,
OverbyteIcsEmulVT, OverbyteIcsTnCnx,
OverbyteIcsTnOptFrm, OverbyteIcsWSocket;
const
TnEmultVTVersion = 600;
CopyRight : String = ' TTnEmulVT (c) 1996-2006 F. Piette V6.00 ';
type
TTnEmulVTDataAvailable = procedure (Sender : TObject;
Buffer : Pointer;
var Len : Integer) of object;
TTnEmulVT = class(TEmulVT)
protected
FTnCnx : TTnCnx;
FError : Word;
FIniFilename : String;
FSectionName : String;
FKeyName : String;
FHostName : String;
FPort : String;
FTag : LongInt;
FUpperLock : Boolean;
FLocalEcho : Boolean;
FOnSessionClosed : TNotifyEvent;
FOnSessionConnected : TNotifyEvent;
FOnNamesClick : TNotifyEvent;
FOnSendLoc : TNotifyEvent;
FOnTermType : TNotifyEvent;
FOnLocalEcho : TNotifyEvent;
FOnDataAvailable : TTnEmulVTDataAvailable;
FMouseDown : Boolean;
FMouseCaptured : Boolean;
FMouseTop : Integer;
FMouseLeft : Integer;
FFocusDrawn : Boolean;
FFocusRect : TRect;
procedure TriggerDataAvailable(Buffer : Pointer; Len: Integer); virtual;
procedure TnCnxDataAvailable(Sender: TTnCnx; Buffer : Pointer; Len : Integer);
procedure TnCnxSessionClosed(Sender: TTnCnx; ErrorCode: Word);
procedure TnCnxSessionConnected(Sender: TTnCnx; ErrorCode: Word);
procedure TnCnxSendLoc(Sender: TObject);
procedure TnCnxTermType(Sender: TObject);
procedure TnCnxLocalEcho(Sender: TObject);
procedure Display(Msg : String);
procedure DoKeyBuffer(Buffer : PChar; Len : Integer); override;
procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer); override;
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
procedure MouseUp(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer); override;
{$IFNDEF BCB_FLAG}
procedure Notification(AComponent : TComponent;
Operation : TOperation); override;
{$ENDIF}
procedure SetOnEndOfRecord(Value : TNotifyEvent);
function GetOnEndOfRecord : TNotifyEvent;
procedure SetLocation(Value : String);
function GetLocation : String;
procedure SetHostName(newValue : String);
public
procedure RequestLocalEcho(newValue : Boolean);
function GetLocalEcho : Boolean;
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Connect;
procedure Disconnect;
procedure EditOptions;
procedure RestoreOptions;
function IsConnected : Boolean;
function Send(Data : Pointer; Len : Integer) : Integer;
function SendStr(Data : String) : Integer;
function GetSelTextBuf(Buffer: PChar; BufSize: Integer): Integer;
procedure KeyPress(var Key: Char); override;
property TnConn : TTnCnx read FTnCnx;
published
property IniFilename : String read FIniFileName write FIniFileName;
property SectionName : String read FSectionName write FSectionName;
property KeyName : String read FKeyName write FKeyName;
property Error : Word read FError write FError;
property HostName : String read FHostName write SetHostName;
property Port : String read FPort write FPort;
property Tag : LongInt read FTag write FTag;
property Location : String read GetLocation write SetLocation;
property UpperLock : Boolean read FUpperLock write FUpperLock;
property LocalEcho : Boolean read FLocalEcho write FLocalEcho;
property OnKeyDown;
property OnSessionClosed : TNotifyEvent read FOnSessionClosed
write FOnSessionClosed;
property OnSessionConnected : TNotifyEvent read FOnSessionConnected
write FOnSessionConnected;
property OnEndOfRecord : TNotifyEvent read GetOnEndOfRecord
write SetOnEndOfRecord;
property OnNamesClick : TNotifyEvent read FOnNamesClick
write FOnNamesClick;
property OnSendLoc : TNotifyEvent read FOnSendLoc
write FOnSendLoc;
property OnTermType : TNotifyEvent read FOnTermType
write FOnTermType;
property OnLocalEcho : TNotifyEvent read FOnLocalEcho
write FOnLocalEcho;
property OnDataAvailable : TTnEmulVTDataAvailable read FOnDataAvailable
write FOnDataAvailable;
end;
procedure Register;
implementation
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure Register;
begin
RegisterComponents('FPiette', [TTnEmulVT]);
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure FontToIni(Font : TFont; IniFile : TIniFile; Section : String);
var
nBuf : Integer;
begin
IniFile.WriteString(Section, 'FontName', Font.Name);
IniFile.WriteInteger(Section, 'FontSize', Font.Size);
IniFile.WriteInteger(Section, 'FontPitch', ord(Font.Pitch));
nBuf := 0;
if fsBold in Font.Style then
nBuf := nBuf or 1;
if fsItalic in Font.Style then
nBuf := nBuf or 2;
if fsUnderline in Font.Style then
nBuf := nBuf or 4;
if fsStrikeOut in Font.Style then
nBuf := nBuf or 8;
IniFile.WriteInteger(Section, 'FontStyle', nBuf);
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure IniToFont(Font : TFont; IniFile : TIniFile; Section : String);
var
FontName : String;
nBuf : Integer;
begin
FontName := IniFile.ReadString(Section, 'FontName', '*');
if FontName <> '*' then begin
Font.Name := FontName;
Font.Size := IniFile.ReadInteger(Section, 'FontSize', 9);
Font.Pitch := TFontPitch(IniFile.ReadInteger(Section, 'FontPitch', 12));
nBuf := IniFile.ReadInteger(Section, 'FontStyle', 0);
Font.Style := [];
if (nBuf and 1) <> 0 then
Font.Style := Font.Style + [fsBold];
if (nBuf and 2) <> 0 then
Font.Style := Font.Style + [fsItalic];
if (nBuf and 4) <> 0 then
Font.Style := Font.Style + [fsUnderline];
if (nBuf and 8) <> 0 then
Font.Style := Font.Style + [fsStrikeOut];
end;
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
constructor TTnEmulVT.Create(AOwner: TComponent);
var
Rect : TRect;
begin
inherited Create(AOwner);
FTnCnx := TTnCnx.Create(Self);
FTnCnx.OnDataAvailable := TnCnxDataAvailable;
FTnCnx.OnSessionClosed := TnCnxSessionClosed;
FTnCnx.OnSessionConnected := TnCnxSessionConnected;
FTnCnx.OnSendLoc := TnCnxSendLoc;
FTnCnx.OnTermType := TnCnxTermType;
FTnCnx.OnLocalEcho := TnCnxLocalEcho;
FIniFileName := 'TNEMULVT.INI';
FSectionName := 'Windows';
FKeyName := 'TnEmulVT';
FPort := 'telnet';
Rect.Top := -1;
SelectRect := Rect;
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
destructor TTnEmulVT.Destroy;
begin
if Assigned(FTnCnx) then begin
FTnCnx.Free;
FTnCnx := nil;
end;
inherited Destroy;
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
{$IFNDEF BCB_FLAG}
procedure TTnEmulVT.Notification(
AComponent : TComponent;
Operation : TOperation);
begin
inherited Notification(AComponent, operation);
if Operation = opRemove then begin
if AComponent = FTnCnx then
FTnCnx:= nil;
end;
end;
{$ENDIF}
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure TTnEmulVT.SetHostName(newValue : String);
begin
FHostName := newValue;
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
function TTnEmulVT.GetLocalEcho : Boolean;
begin
if Assigned(FTnCnx) then
Result := FTnCnx.LocalEcho
else
Result := FALSE;
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure TTnEmulVT.RequestLocalEcho(newValue : Boolean);
begin
if Assigned(FTnCnx) then begin
if newValue then
FTnCnx.DontOption(TN_ECHO)
else
FTnCnx.DoOption(TN_ECHO);
end;
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure TTnEmulVT.SetLocation(Value : String);
begin
if Assigned(FTnCnx) then
FTnCnx.Location := Value;
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
function TTnEmulVT.GetLocation : String;
begin
if Assigned(FTnCnx) then
Result := FTnCnx.Location;
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure TTnEmulVT.Display(Msg : String);
begin
WriteStr(Msg);
Repaint;
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure TTnEmulVT.SetOnEndOfRecord(Value : TNotifyEvent);
begin
if Assigned(FTnCnx) then
FTnCnx.OnEndOfRecord := Value;
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
function TTnEmulVT.GetOnEndOfRecord : TNotifyEvent;
begin
if Assigned(FTnCnx) then
Result := FTnCnx.OnEndOfRecord;
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure TTnEmulVT.TnCnxSendLoc(Sender: TObject);
begin
if Assigned(FOnSendLoc) then
FOnSendLoc(Self);
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure TTnEmulVT.TnCnxTermType(Sender: TObject);
begin
if Assigned(FOnTermType) then
FOnTermType(Self);
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure TTnEmulVT.TnCnxLocalEcho(Sender: TObject);
begin
if Assigned(FOnLocalEcho) then
FOnLocalEcho(Self);
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure TTnEmulVT.TriggerDataAvailable(Buffer : Pointer; Len: Integer);
begin
if Assigned(FOnDataAvailable) then
FOnDataAvailable(Self, Buffer, Len);
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure TTnEmulVT.TnCnxDataAvailable(Sender: TTnCnx; Buffer : Pointer;
Len: Integer);
var
I : Integer;
begin
TriggerDataAvailable(Buffer, Len);
if Len <= 0 then
Exit;
for I := 0 to Len - 1 do begin
try
WriteChar((PChar(Buffer) + I)^);
except
Break;
end;
end;
UpdateScreen;
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure TTnEmulVT.TnCnxSessionClosed(Sender: TTnCnx; ErrorCode: Word);
begin
Display(#13 + #10 + '*** Server has closed ***' + #13 + #10);
MessageBeep(MB_ICONASTERISK);
FError := ErrorCode;
if Assigned(FOnSessionClosed) then
FOnSessionClosed(Self);
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure TTnEmulVT.TnCnxSessionConnected(Sender: TTnCnx; ErrorCode: Word);
begin
if ErrorCode = 0 then begin
Display('Connected' + #13 + #10);
end
else begin
Display('Connection failed: ' +
WSocketErrorDesc(ErrorCode) +
#13 + #10);
MessageBeep(MB_ICONASTERISK);
end;
FError := ErrorCode;
if Assigned(FOnSessionConnected) then
FOnSessionConnected(Self);
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure TTnEmulVT.RestoreOptions;
var
IniFile : TIniFile;
xFont : TFont;
begin
if Length(FHostname) <= 0 then
Exit;
IniFile := TIniFile.Create(IniFilename);
xFont := TFont.Create;
IniToFont(xFont, IniFile, HostName);
Font := xFont;
xFont.Free;
LineHeight := IniFile.ReadInteger(HostName, 'LineHeight', 12);
Rows := IniFile.ReadInteger(HostName, 'Rows', 25);
Cols := IniFile.ReadInteger(HostName, 'Cols', 80);
FKeys := IniFile.ReadInteger(HostName, 'FKeys', 0);
AutoCr := IniFile.ReadInteger(HostName, 'AutoCR', 0) <> 0;
AutoLF := IniFile.ReadInteger(HostName, 'AutoLF', 0) <> 0;
LocalEcho := IniFile.ReadInteger(HostName, 'LocalEcho', 0) <> 0;
MonoChrome := IniFile.ReadInteger(HostName, 'MonoChrome', 0) <> 0;
UpperLock := IniFile.ReadInteger(HostName, 'UpperLock', 0) <> 0;
Xlat := IniFile.ReadInteger(HostName, 'Xlat', 0) <> 0;
GraphicDraw := IniFile.ReadInteger(HostName, 'GraphicDraw', 0) <> 0;
CharZoom := StrToFloat(IniFile.ReadString(HostName, 'CharZoom', '1'));
LineZoom := StrToFloat(IniFile.ReadString(HostName, 'LineZoom', '1'));
IniFile.Free;
end;
{* * * * * * * * * * * * * * * * * * * * * * ** * * * * * * * * * * * * * *}
procedure TTnEmulVT.Connect;
var
{$IFDEF VER80} { Delphi 1 }
Form : TForm;
{$ELSE}
{$IFDEF VER90} { Delphi 2 }
Form : TForm;
{$ELSE}
{$IFDEF VER93} { Bcb 1 }
Form : TForm;
{$ELSE} { Delphi 3/4, Bcb 3/4 }
Form : TCustomForm;
{$ENDIF}
{$ENDIF}
{$ENDIF}
begin
if Length(FHostname) <= 0 then
Exit;
Clear;
if not Assigned(FTnCnx) then
Exit;
FTnCnx.Port := FPort;
FTnCnx.Host := FHostName;
FTnCnx.Connect;
Display('Connecting to ''' + HostName + '''' + #13 + #10);
Form := GetParentForm(Self);
Form.ActiveControl := Self;
end;
{* * * * * * * * * * * * * * * * * * * * * * ** * * * * * * * * * * * * * *}
procedure TTnEmulVT.Disconnect;
begin
if Assigned(FTnCnx) then
FTnCnx.Close;
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
function TTnEmulVT.Send(Data : Pointer; Len : Integer) : Integer;
begin
if Assigned(FTnCnx) then
Result := FTnCnx.Send(Data, Len)
else
Result := 0;
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
function TTnEmulVT.SendStr(Data : String) : Integer;
begin
if Assigned(FTnCnx) then
Result := FTnCnx.SendStr(Data)
else
Result := 0;
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
function TTnEmulVT.IsConnected : Boolean;
begin
if Assigned(FTnCnx) then
Result := FTnCnx.IsConnected
else
Result := FALSE;
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure TTnEmulVT.EditOptions;
var
IniFile : TIniFile;
begin
if Length(FHostname) <= 0 then
Exit;
if OptForm = nil then
OptForm := TOptForm.Create(Self);
OptForm.IniFileName := FIniFileName;
OptForm.OnNamesClick := FOnNamesClick;
RestoreOptions;
OptForm.AFont.Assign(Font);
OptForm.LineHeight := LineHeight;
OptForm.AutoCR := AutoCr;
OptForm.AutoLF := AutoLF;
OptForm.LocalEcho := LocalEcho;
OptForm.MonoChrome := MonoChrome;
OptForm.UpperLock := UpperLock;
OptForm.Xlat := Xlat;
OptForm.GraphicDraw := GraphicDraw;
OptForm.Rows := Rows;
OptForm.Cols := Cols;
OptForm.HostName := FHostName;
OptForm.FKeys := FKeys;
OptForm.CharZoom := CharZoom;
OptForm.LineZoom := LineZoom;
if OptForm.ShowModal = IDOK then begin
Font := OptForm.AFont;
LineHeight := OptForm.LineHeight;
AutoCR := OptForm.AutoCr;
AutoLF := OptForm.AutoLF;
LocalEcho := OptForm.LocalEcho;
MonoChrome := OptForm.MonoChrome;
UpperLock := OptForm.UpperLock;
Xlat := OptForm.Xlat;
GraphicDraw := OptForm.GraphicDraw;
Rows := OptForm.Rows;
Cols := OptForm.Cols;
FKeys := OptForm.FKeys;
LineZoom := OptForm.LineZoom;
CharZoom := OptForm.CharZoom;
IniFile := TIniFile.Create(FIniFilename);
FontToIni(OptForm.AFont, IniFile, FHostName);
IniFile.WriteInteger(FHostName, 'LineHeight', LineHeight);
IniFile.WriteInteger(FHostName, 'Rows', Rows);
IniFile.WriteInteger(FHostName, 'Cols', Cols);
IniFile.WriteInteger(FHostName, 'AutoCR', ord(AutoCR));
IniFile.WriteInteger(FHostName, 'AutoLF', ord(AutoLF));
IniFile.WriteInteger(FHostName, 'LocalEcho', ord(LocalEcho));
IniFile.WriteInteger(FHostName, 'MonoChrome', ord(MonoChrome));
IniFile.WriteInteger(FHostName, 'UpperLock', ord(UpperLock));
IniFile.WriteInteger(FHostName, 'Xlat', ord(Xlat));
IniFile.WriteInteger(FHostName, 'GraphicDraw', ord(GraphicDraw));
IniFile.WriteInteger(FHostName, 'FKeys', FKeys);
IniFile.WriteString(FHostName, 'LineZoom', Format('%5.3f', [LineZoom]));
IniFile.WriteString(FHostName, 'CharZoom', Format('%5.3f', [CharZoom]));
IniFile.Free;
Repaint;
end;
end;
{* * * * * * * * * * * * * * * * * * * * * * ** * * * * * * * * * * * * * *}
procedure TTnEmulVT.KeyPress(var Key: Char);
begin
inherited KeyPress(Key);
if FUpperLock and (Key in ['a'..'z']) then
Key := chr(ord(Key) and $DF);
if Key <> #0 then begin
try
if FLocalEcho then
WriteChar(Key);
if Assigned(FTnCnx) then
FTnCnx.Send(@Key, 1);
except
{ Ignore any exception ! }
end;
end;
end;
{* * * * * * * * * * * * * * * * * * * * * * ** * * * * * * * * * * * * * *}
procedure TTnEmulVT.DoKeyBuffer(Buffer : PChar; Len : Integer);
begin
try
if FLocalEcho then
WriteBuffer(Buffer, Len);
if Assigned(FTnCnx) then
FTnCnx.Send(Buffer, Len);
except
{ Ignore exception ! }
end;
end;
{* * * * * * * * * * * * * * * * * * * * * * ** * * * * * * * * * * * * * *}
procedure DrawFocusRectangle(Wnd: HWnd; Rect: TRect);
var
DC : HDC;
begin
DC := GetDC(Wnd);
DrawFocusRect(DC, Rect);
ReleaseDC(Wnd, DC);
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure TTnEmulVT.MouseDown(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer);
begin
inherited MouseDown(Button, Shift, X, Y);
FMouseDown := TRUE;
if FFocusDrawn then begin
DrawFocusRectangle(Handle, FFocusRect);
FFocusDrawn := FALSE;
end;
if SelectRect.Top <> -1 then begin
FFocusRect.Top := -1;
SelectRect := FFocusRect;
Repaint;
end;
end;
{* * * * * * * * * * * * * * * * * * * * * * ** * * * * * * * * * * * * * *}
procedure TTnEmulVT.MouseMove(Shift: TShiftState; X, Y: Integer);
var
Rect : TRect;
Point : TPoint;
begin
inherited MouseMove(Shift, X, Y);
if not FMouseDown then
Exit;
if not FMouseCaptured then begin
SetCapture(Handle);
FMouseCaptured := TRUE;
FMouseTop := SnapPixelToRow(Y);
FMouseLeft := SnapPixelToCol(X);
Point.X := 0;
Point.Y := 0;
Rect.TopLeft := ClientToScreen(Point);
Point.X := Width - 16;
Point.Y := Height;
Rect.BottomRight := ClientToScreen(Point);
ClipCursor(@Rect);
end
else if (FMouseTop <> Y) or (FMouseLeft <> X) then begin
if FFocusDrawn then
DrawFocusRectangle(Handle, FFocusRect);
Rect.Top := FMouseTop;
Rect.Left := FMouseLeft;
Rect.Bottom := SnapPixelToRow(Y) + LineHeight + 4;
Rect.Right := SnapPixelToCol(X) + CharWidth;
DrawFocusRectangle(Handle, Rect);
FFocusRect := Rect;
FFocusDrawn := TRUE;
end;
end;
{* * * * * * * * * * * * * * * * * * * * * * ** * * * * * * * * * * * * * *}
procedure TTnEmulVT.MouseUp(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer);
begin
inherited MouseUp(Button, Shift, X, Y);
FMouseDown := FALSE;
if FMouseCaptured then begin
ReleaseCapture;
FMouseCaptured := FALSE;
ClipCursor(nil);
end;
if FFocusDrawn then begin
DrawFocusRectangle(Handle, FFocusRect);
FFocusDrawn := FALSE;
if (FFocusRect.Right - FFocusRect.Left) < CharWidth then
FFocusRect.Top := -1;
if (FFocusRect.Bottom - FFocusRect.Top) < LineHeight then
FFocusRect.Top := -1;
SelectRect := FFocusRect;
Repaint;
end;
end;
{* * * * * * * * * * * * * * * * * * * * * * ** * * * * * * * * * * * * * *}
function TTnEmulVT.GetSelTextBuf(Buffer: PChar; BufSize: Integer): Integer;
var
StartRow : Integer;
StopRow : Integer;
StartCol : Integer;
StopCol : Integer;
nRow : Integer;
nCol : Integer;
Line : TLine;
nCnt : Integer;
begin
nCnt := 0;
if (SelectRect.Top = -1) or (BufSize < 1) then begin
if BufSize > 0 then
Buffer[0] := #0;
Result := nCnt;
Exit;
end;
StartRow := PixelToRow(SelectRect.Top);
StopRow := PixelToRow(SelectRect.Bottom) - 1;
StartCol := PixelToCol(SelectRect.Left);
StopCol := PixelToCol(SelectRect.Right) - 1;
for nRow := StartRow to StopRow do begin
if BufSize < 2 then
Break;
Line := Screen.FLines^[Rows - 1 - nRow];
for nCol := StartCol to StopCol do begin
Buffer[0] := Line.Txt[nCol];
Inc(Buffer);
Dec(BufSize);
Inc(nCnt);
if BufSize < 2 then
Break;
end;
if nRow < StopRow then begin
if BufSize < 4 then
Break;
Buffer[0] := #13;
Buffer[1] := #10;
Inc(Buffer);
Inc(Buffer);
Dec(BufSize);
Dec(BufSize);
Inc(nCnt);
Inc(nCnt);
end;
end;
Buffer[0] := #0;
Result := nCnt;
end;
{* * * * * * * * * * * * * * * * * * * * * * ** * * * * * * * * * * * * * *}
end.
|
unit uMainForm;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes,
System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, IdContext,
IdCustomHTTPServer, IdBaseComponent, IdComponent, IdCustomTCPServer,
IdHTTPServer, FMX.Media, FMX.Objects, FMX.StdCtrls, FMX.Controls.Presentation,
IdSync, FMX.Edit, FMX.EditBox, FMX.NumberBox;
type
TMainForm = class(TForm)
ToolBar1: TToolBar;
butStartVideo: TButton;
butStartStream: TButton;
imgCameraView: TImage;
CameraComponent: TCameraComponent;
IdHTTPServer: TIdHTTPServer;
edtPort: TEdit;
Label1: TLabel;
StyleBook: TStyleBook;
procedure FormShow(Sender: TObject);
procedure IdHTTPServerCommandGet(AContext: TIdContext;
ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
procedure CameraComponentSampleBufferReady(Sender: TObject;
const ATime: TMediaTime);
procedure butStartVideoClick(Sender: TObject);
procedure butStartStreamClick(Sender: TObject);
private
{ Private declarations }
procedure GetImage;
public
{ Public declarations }
end;
type
TGetImageStream = class(TIdSync)
protected
FStream: TStream;
procedure DoSynchronize; override;
public
class procedure GetImage(aStream: TStream);
end;
var
MainForm: TMainForm;
implementation
{$R *.fmx}
{$R *.LgXhdpiPh.fmx ANDROID}
{$R *.iPad.fmx IOS}
uses FMX.Surfaces;
procedure TMainForm.butStartStreamClick(Sender: TObject);
begin
IdHTTPServer.DefaultPort := StrtoInt(edtPort.Text);
IdHTTPServer.Active := not IdHTTPServer.Active;
if IdHTTPServer.Active then
butStartStream.Text := 'Stop Stream'
else
butStartStream.Text := 'Start Stream';
end;
procedure TMainForm.butStartVideoClick(Sender: TObject);
begin
CameraComponent.Active := not CameraComponent.Active;
if CameraComponent.Active then
butStartVideo.Text := 'Stop Video'
else
butStartVideo.Text := 'Start Video';
end;
procedure TMainForm.CameraComponentSampleBufferReady(Sender: TObject;
const ATime: TMediaTime);
begin
TThread.Queue(TThread.CurrentThread, GetImage);
end;
procedure TMainForm.GetImage;
begin
CameraComponent.SampleBufferToBitmap(imgCameraView.Bitmap, True);
end;
procedure TMainForm.FormShow(Sender: TObject);
begin
CameraComponent.Kind := TCameraKind.BackCamera;
CameraComponent.Quality := TVideoCaptureQuality.LowQuality;
CameraComponent.CaptureSettingPriority :=
TVideoCaptureSettingPriority.FrameRate;
end;
{ TGetImageStream }
procedure TGetImageStream.DoSynchronize;
begin
inherited;
MainForm.imgCameraView.Bitmap.SaveToStream(FStream);
end;
class procedure TGetImageStream.GetImage(aStream: TStream);
begin
with Create do
try
FStream := aStream;
Synchronize;
finally
Free;
end;
end;
procedure TMainForm.IdHTTPServerCommandGet(AContext: TIdContext;
ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
var
LStream: TMemoryStream;
begin
LStream := TMemoryStream.Create;
try
TGetImageStream.GetImage(LStream);
LStream.Position := 0;
except
LStream.Free;
raise;
end;
AResponseInfo.ResponseNo := 200;
AResponseInfo.ContentType := 'image/bmp';
AResponseInfo.ContentStream := LStream;
end;
end.
|
unit nevVScrollerSpy;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Библиотека "Everest"
// Модуль: "w:/common/components/gui/Garant/Everest/new/nevVScrollerSpy.pas"
// Родные Delphi интерфейсы (.pas)
// Generated from UML model, root element: <<SimpleClass::Class>> Shared Delphi::Everest::Views::TnevVScrollerSpy
//
//
// Все права принадлежат ООО НПП "Гарант-Сервис".
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ! Полностью генерируется с модели. Править руками - нельзя. !
{$Include w:\common\components\gui\Garant\Everest\evDefine.inc}
interface
uses
l3Filer,
l3ProtoObject
;
type
InevVScrollerPosLogger = interface(IUnknown)
['{118E1374-07D5-47D3-B4EF-C921BCC2BA51}']
function OpenLog: AnsiString;
procedure CloseLog(const aLogName: AnsiString);
end;//InevVScrollerPosLogger
TnevVScrollerSpy = class(Tl3ProtoObject)
private
// private fields
f_LogName : AnsiString;
f_Logger : InevVScrollerPosLogger;
f_Filer : Tl3CustomFiler;
protected
// overridden protected methods
procedure Cleanup; override;
{* Функция очистки полей объекта. }
procedure ClearFields; override;
public
// public methods
procedure SetLogger(const aLogger: InevVScrollerPosLogger);
procedure RemoveLogger(const aLogger: InevVScrollerPosLogger);
procedure LogPos(aPos: Integer);
function StartLog: Boolean;
procedure FinishLog;
class function Exists: Boolean;
public
// singleton factory method
class function Instance: TnevVScrollerSpy;
{- возвращает экземпляр синглетона. }
end;//TnevVScrollerSpy
implementation
uses
l3Base {a},
SysUtils,
l3Types
;
// start class TnevVScrollerSpy
var g_TnevVScrollerSpy : TnevVScrollerSpy = nil;
procedure TnevVScrollerSpyFree;
begin
l3Free(g_TnevVScrollerSpy);
end;
class function TnevVScrollerSpy.Instance: TnevVScrollerSpy;
begin
if (g_TnevVScrollerSpy = nil) then
begin
l3System.AddExitProc(TnevVScrollerSpyFree);
g_TnevVScrollerSpy := Create;
end;
Result := g_TnevVScrollerSpy;
end;
procedure TnevVScrollerSpy.SetLogger(const aLogger: InevVScrollerPosLogger);
//#UC START# *4DAEBD9D0238_4DAEB03E0034_var*
//#UC END# *4DAEBD9D0238_4DAEB03E0034_var*
begin
//#UC START# *4DAEBD9D0238_4DAEB03E0034_impl*
Assert(f_Logger = nil);
f_Logger := aLogger;
//#UC END# *4DAEBD9D0238_4DAEB03E0034_impl*
end;//TnevVScrollerSpy.SetLogger
procedure TnevVScrollerSpy.RemoveLogger(const aLogger: InevVScrollerPosLogger);
//#UC START# *4DAEBDF20386_4DAEB03E0034_var*
//#UC END# *4DAEBDF20386_4DAEB03E0034_var*
begin
//#UC START# *4DAEBDF20386_4DAEB03E0034_impl*
Assert(f_Logger = aLogger);
f_Logger := nil;
//#UC END# *4DAEBDF20386_4DAEB03E0034_impl*
end;//TnevVScrollerSpy.RemoveLogger
procedure TnevVScrollerSpy.LogPos(aPos: Integer);
//#UC START# *4DAEBE61037F_4DAEB03E0034_var*
//#UC END# *4DAEBE61037F_4DAEB03E0034_var*
begin
//#UC START# *4DAEBE61037F_4DAEB03E0034_impl*
if (f_Logger <> nil) then
begin
Assert(f_Filer <> nil);
Assert(f_Filer.Opened);
f_Filer.WriteLn('Позиция скроллера: ' + IntToStr(aPos));
end;//f_Logger <> nil
//#UC END# *4DAEBE61037F_4DAEB03E0034_impl*
end;//TnevVScrollerSpy.LogPos
function TnevVScrollerSpy.StartLog: Boolean;
//#UC START# *4DAEBE840395_4DAEB03E0034_var*
//#UC END# *4DAEBE840395_4DAEB03E0034_var*
begin
//#UC START# *4DAEBE840395_4DAEB03E0034_impl*
Result := f_Logger <> nil;
f_LogName := f_Logger.OpenLog;
f_Filer := Tl3CustomDOSFiler.Make(f_LogName, l3_fmWrite);
try
f_Filer.Open;
except
l3Free(f_Filer);
end;
//#UC END# *4DAEBE840395_4DAEB03E0034_impl*
end;//TnevVScrollerSpy.StartLog
procedure TnevVScrollerSpy.FinishLog;
//#UC START# *4DAEBEBC016B_4DAEB03E0034_var*
//#UC END# *4DAEBEBC016B_4DAEB03E0034_var*
begin
//#UC START# *4DAEBEBC016B_4DAEB03E0034_impl*
try
if f_Filer <> nil then
f_Filer.Close;
finally
try
FreeAndNil(f_Filer);
finally
f_Logger.CloseLog(f_LogName);
f_LogName := '';
end;
end;
//#UC END# *4DAEBEBC016B_4DAEB03E0034_impl*
end;//TnevVScrollerSpy.FinishLog
class function TnevVScrollerSpy.Exists: Boolean;
//#UC START# *4DAECA8C027C_4DAEB03E0034_var*
//#UC END# *4DAECA8C027C_4DAEB03E0034_var*
begin
//#UC START# *4DAECA8C027C_4DAEB03E0034_impl*
Result := g_TnevVScrollerSpy <> nil;
//#UC END# *4DAECA8C027C_4DAEB03E0034_impl*
end;//TnevVScrollerSpy.Exists
procedure TnevVScrollerSpy.Cleanup;
//#UC START# *479731C50290_4DAEB03E0034_var*
//#UC END# *479731C50290_4DAEB03E0034_var*
begin
//#UC START# *479731C50290_4DAEB03E0034_impl*
FreeAndNil(f_Filer);
inherited;
//#UC END# *479731C50290_4DAEB03E0034_impl*
end;//TnevVScrollerSpy.Cleanup
procedure TnevVScrollerSpy.ClearFields;
{-}
begin
f_Logger := nil;
inherited;
end;//TnevVScrollerSpy.ClearFields
end. |
{ *********************************************************** }
{ * TForge Library * }
{ * Copyright (c) Sergey Kasandrov 1997, 2016 * }
{ *********************************************************** }
unit tfSHA256;
{$I TFL.inc}
{$IFDEF TFL_CPUX86_WIN32}
{$DEFINE CPUX86_WIN32}
{$ENDIF}
{$IFDEF TFL_CPUX64_WIN64}
{$DEFINE CPUX64_WIN64}
{$ENDIF}
interface
uses tfTypes;
type
PSHA256Alg = ^TSHA256Alg;
TSHA256Alg = record
private type
TData = record
Digest: TSHA256Digest;
Block: array[0..63] of Byte;
Count: UInt64; // number of bytes processed
end;
private
FVTable: Pointer;
FRefCount: Integer;
FData: TData;
procedure Compress;
public
class procedure Init(Inst: PSHA256Alg);
{$IFDEF TFL_STDCALL}stdcall;{$ENDIF} static;
class procedure Update(Inst: PSHA256Alg; Data: PByte; DataSize: Cardinal);
{$IFDEF TFL_STDCALL}stdcall;{$ENDIF} static;
class procedure Done(Inst: PSHA256Alg; PDigest: PSHA256Digest);
{$IFDEF TFL_STDCALL}stdcall;{$ENDIF} static;
class function GetDigestSize(Inst: PSHA256Alg): Integer;
{$IFDEF TFL_STDCALL}stdcall;{$ENDIF} static;
class function GetBlockSize(Inst: PSHA256Alg): Integer;
{$IFDEF TFL_STDCALL}stdcall;{$ENDIF} static;
class function Duplicate(Inst: PSHA256Alg; var DupInst: PSHA256Alg): TF_RESULT;
{$IFDEF TFL_STDCALL}stdcall;{$ENDIF} static;
end;
type
PSHA224Alg = ^TSHA224Alg;
TSHA224Alg = record
private type
TData = record
Digest: TSHA256Digest; // !! 256 bits
Block: array[0..63] of Byte;
Count: UInt64; // number of bytes processed
end;
private
FVTable: Pointer;
FRefCount: Integer;
FData: TData;
public
class procedure Init(Inst: PSHA224Alg);
{$IFDEF TFL_STDCALL}stdcall;{$ENDIF} static;
class procedure Done(Inst: PSHA224Alg; PDigest: PSHA224Digest);
{$IFDEF TFL_STDCALL}stdcall;{$ENDIF} static;
class function GetDigestSize(Inst: PSHA256Alg): Integer;
{$IFDEF TFL_STDCALL}stdcall;{$ENDIF} static;
end;
function GetSHA256Algorithm(var Inst: PSHA256Alg): TF_RESULT;
function GetSHA224Algorithm(var Inst: PSHA224Alg): TF_RESULT;
implementation
uses tfRecords;
const
SHA256VTable: array[0..9] of Pointer = (
@TForgeInstance.QueryIntf,
@TForgeInstance.Addref,
@HashAlgRelease,
@TSHA256Alg.Init,
@TSHA256Alg.Update,
@TSHA256Alg.Done,
@TSHA256Alg.Init,
@TSHA256Alg.GetDigestSize,
@TSHA256Alg.GetBlockSize,
@TSHA256Alg.Duplicate
);
const
SHA224VTable: array[0..9] of Pointer = (
@TForgeInstance.QueryIntf,
@TForgeInstance.Addref,
@HashAlgRelease,
@TSHA224Alg.Init,
@TSHA256Alg.Update,
@TSHA224Alg.Done,
@TSHA224Alg.Init,
@TSHA224Alg.GetDigestSize,
@TSHA256Alg.GetBlockSize,
@TSHA256Alg.Duplicate
);
function GetSHA256Algorithm(var Inst: PSHA256Alg): TF_RESULT;
var
P: PSHA256Alg;
begin
try
New(P);
P^.FVTable:= @SHA256VTable;
P^.FRefCount:= 1;
TSHA256Alg.Init(P);
if Inst <> nil then HashAlgRelease(Inst);
Inst:= P;
Result:= TF_S_OK;
except
Result:= TF_E_OUTOFMEMORY;
end;
end;
function GetSHA224Algorithm(var Inst: PSHA224Alg): TF_RESULT;
var
P: PSHA224Alg;
begin
try
New(P);
P^.FVTable:= @SHA224VTable;
P^.FRefCount:= 1;
TSHA224Alg.Init(P);
if Inst <> nil then HashAlgRelease(Inst);
Inst:= P;
Result:= TF_S_OK;
except
Result:= TF_E_OUTOFMEMORY;
end;
end;
{ TSHA256Algorithm }
function Swap32(Value: UInt32): UInt32;
begin
Result:= ((Value and $FF) shl 24) or ((Value and $FF00) shl 8) or
((Value and $FF0000) shr 8) or ((Value and $FF000000) shr 24);
end;
{$IFNDEF CPUX86_WIN32}
{$IFNDEF CPUX64_WIN64}
procedure TSHA256Alg.Compress;
type
PLongArray = ^TLongArray;
TLongArray = array[0..15] of UInt32;
var
W: PLongArray;
// W: array[0..63] of UInt32;
a, b, c, d, e, f, g, h, t1, t2: UInt32;
// I: UInt32;
begin
W:= @FData.Block;
a:= FData.Digest[0];
b:= FData.Digest[1];
c:= FData.Digest[2];
d:= FData.Digest[3];
e:= FData.Digest[4];
f:= FData.Digest[5];
g:= FData.Digest[6];
h:= FData.Digest[7];
// Move(FData.Block, W, SizeOf(FData.Block));
{ for I:= 0 to 15 do
W[I]:= Swap32(W[I]);
for I:= 16 to 63 do
W[I]:= (((W[I-2] shr 17) or (W[I-2] shl 15)) xor
((W[I-2] shr 19) or (W[I-2] shl 13)) xor (W[I-2] shr 10)) + W[I-7] +
(((W[I-15] shr 7) or (W[I-15] shl 25)) xor
((W[I-15] shr 18) or (W[I-15] shl 14)) xor (W[I-15] shr 3)) + W[I-16];
}
W[0]:= Swap32(W[0]);
t1:= h + (((e shr 6) or (e shl 26)) xor ((e shr 11) or (e shl 21)) xor
((e shr 25) or (e shl 7))) + ((e and f) xor (not e and g)) + $428a2f98 + W[0];
t2:= (((a shr 2) or (a shl 30)) xor ((a shr 13) or (a shl 19)) xor
((a shr 22) xor (a shl 10))) + ((a and b) xor (a and c) xor (b and c));
h:= t1 + t2;
d:= d + t1;
W[1]:= Swap32(W[1]);
t1:= g + (((d shr 6) or (d shl 26)) xor ((d shr 11) or (d shl 21)) xor
((d shr 25) or (d shl 7))) + ((d and e) xor (not d and f)) + $71374491 + W[1];
t2:= (((h shr 2) or (h shl 30)) xor ((h shr 13) or (h shl 19)) xor
((h shr 22) xor (h shl 10))) + ((h and a) xor (h and b) xor (a and b));
g:= t1 + t2;
c:= c + t1;
W[2]:= Swap32(W[2]);
t1:= f + (((c shr 6) or (c shl 26)) xor ((c shr 11) or (c shl 21)) xor
((c shr 25) or (c shl 7))) + ((c and d) xor (not c and e)) + $b5c0fbcf + W[2];
t2:= (((g shr 2) or (g shl 30)) xor ((g shr 13) or (g shl 19)) xor
((g shr 22) xor (g shl 10))) + ((g and h) xor (g and a) xor (h and a));
f:= t1 + t2;
b:= b + t1;
W[3]:= Swap32(W[3]);
t1:= e + (((b shr 6) or (b shl 26)) xor ((b shr 11) or (b shl 21)) xor
((b shr 25) or (b shl 7))) + ((b and c) xor (not b and d)) + $e9b5dba5 + W[3];
t2:= (((f shr 2) or (f shl 30)) xor ((f shr 13) or (f shl 19)) xor
((f shr 22) xor (f shl 10))) + ((f and g) xor (f and h) xor (g and h));
e:= t1 + t2;
a:= a + t1;
W[4]:= Swap32(W[4]);
t1:= d + (((a shr 6) or (a shl 26)) xor ((a shr 11) or (a shl 21)) xor
((a shr 25) or (a shl 7))) + ((a and b) xor (not a and c)) + $3956c25b + W[4];
t2:= (((e shr 2) or (e shl 30)) xor ((e shr 13) or (e shl 19)) xor
((e shr 22) xor (e shl 10))) + ((e and f) xor (e and g) xor (f and g));
d:= t1 + t2;
h:= h + t1;
W[5]:= Swap32(W[5]);
t1:= c + (((h shr 6) or (h shl 26)) xor ((h shr 11) or (h shl 21)) xor
((h shr 25) or (h shl 7))) + ((h and a) xor (not h and b)) + $59f111f1 + W[5];
t2:= (((d shr 2) or (d shl 30)) xor ((d shr 13) or (d shl 19)) xor
((d shr 22) xor (d shl 10))) + ((d and e) xor (d and f) xor (e and f));
c:= t1 + t2;
g:= g + t1;
W[6]:= Swap32(W[6]);
t1:= b + (((g shr 6) or (g shl 26)) xor ((g shr 11) or (g shl 21)) xor
((g shr 25) or (g shl 7))) + ((g and h) xor (not g and a)) + $923f82a4 + W[6];
t2:= (((c shr 2) or (c shl 30)) xor ((c shr 13) or (c shl 19)) xor
((c shr 22) xor (c shl 10))) + ((c and d) xor (c and e) xor (d and e));
b:= t1 + t2;
f:= f + t1;
W[7]:= Swap32(W[7]);
t1:= a + (((f shr 6) or (f shl 26)) xor ((f shr 11) or (f shl 21)) xor
((f shr 25) or (f shl 7))) + ((f and g) xor (not f and h)) + $ab1c5ed5 + W[7];
t2:= (((b shr 2) or (b shl 30)) xor ((b shr 13) or (b shl 19)) xor
((b shr 22) xor (b shl 10))) + ((b and c) xor (b and d) xor (c and d));
a:= t1 + t2;
e:= e + t1;
W[8]:= Swap32(W[8]);
t1:= h + (((e shr 6) or (e shl 26)) xor ((e shr 11) or (e shl 21)) xor
((e shr 25) or (e shl 7))) + ((e and f) xor (not e and g)) + $d807aa98 + W[8];
t2:= (((a shr 2) or (a shl 30)) xor ((a shr 13) or (a shl 19)) xor
((a shr 22) xor (a shl 10))) + ((a and b) xor (a and c) xor (b and c));
h:= t1 + t2;
d:= d + t1;
W[9]:= Swap32(W[9]);
t1:= g + (((d shr 6) or (d shl 26)) xor ((d shr 11) or (d shl 21)) xor
((d shr 25) or (d shl 7))) + ((d and e) xor (not d and f)) + $12835b01 + W[9];
t2:= (((h shr 2) or (h shl 30)) xor ((h shr 13) or (h shl 19)) xor
((h shr 22) xor (h shl 10))) + ((h and a) xor (h and b) xor (a and b));
g:= t1 + t2;
c:= c + t1;
W[10]:= Swap32(W[10]);
t1:= f + (((c shr 6) or (c shl 26)) xor ((c shr 11) or (c shl 21)) xor
((c shr 25) or (c shl 7))) + ((c and d) xor (not c and e)) + $243185be + W[10];
t2:= (((g shr 2) or (g shl 30)) xor ((g shr 13) or (g shl 19)) xor
((g shr 22) xor (g shl 10))) + ((g and h) xor (g and a) xor (h and a));
f:= t1 + t2;
b:= b + t1;
W[11]:= Swap32(W[11]);
t1:= e + (((b shr 6) or (b shl 26)) xor ((b shr 11) or (b shl 21)) xor
((b shr 25) or (b shl 7))) + ((b and c) xor (not b and d)) + $550c7dc3 + W[11];
t2:= (((f shr 2) or (f shl 30)) xor ((f shr 13) or (f shl 19)) xor
((f shr 22) xor (f shl 10))) + ((f and g) xor (f and h) xor (g and h));
e:= t1 + t2;
a:= a + t1;
W[12]:= Swap32(W[12]);
t1:= d + (((a shr 6) or (a shl 26)) xor ((a shr 11) or (a shl 21)) xor
((a shr 25) or (a shl 7))) + ((a and b) xor (not a and c)) + $72be5d74 + W[12];
t2:= (((e shr 2) or (e shl 30)) xor ((e shr 13) or (e shl 19)) xor
((e shr 22) xor (e shl 10))) + ((e and f) xor (e and g) xor (f and g));
d:= t1 + t2;
h:= h + t1;
W[13]:= Swap32(W[13]);
t1:= c + (((h shr 6) or (h shl 26)) xor ((h shr 11) or (h shl 21)) xor
((h shr 25) or (h shl 7))) + ((h and a) xor (not h and b)) + $80deb1fe + W[13];
t2:= (((d shr 2) or (d shl 30)) xor ((d shr 13) or (d shl 19)) xor
((d shr 22) xor (d shl 10))) + ((d and e) xor (d and f) xor (e and f));
c:= t1 + t2;
g:= g + t1;
W[14]:= Swap32(W[14]);
t1:= b + (((g shr 6) or (g shl 26)) xor ((g shr 11) or (g shl 21)) xor
((g shr 25) or (g shl 7))) + ((g and h) xor (not g and a)) + $9bdc06a7 + W[14];
t2:= (((c shr 2) or (c shl 30)) xor ((c shr 13) or (c shl 19)) xor
((c shr 22) xor (c shl 10))) + ((c and d) xor (c and e) xor (d and e));
b:= t1 + t2;
f:= f + t1;
W[15]:= Swap32(W[15]);
t1:= a + (((f shr 6) or (f shl 26)) xor ((f shr 11) or (f shl 21)) xor
((f shr 25) or (f shl 7))) + ((f and g) xor (not f and h)) + $c19bf174 + W[15];
t2:= (((b shr 2) or (b shl 30)) xor ((b shr 13) or (b shl 19)) xor
((b shr 22) xor (b shl 10))) + ((b and c) xor (b and d) xor (c and d));
a:= t1 + t2;
e:= e + t1;
W[0]:= (((W[14] shr 17) or (W[14] shl 15)) xor
((W[14] shr 19) or (W[14] shl 13)) xor (W[14] shr 10)) + W[9] +
(((W[1] shr 7) or (W[1] shl 25)) xor
((W[1] shr 18) or (W[1] shl 14)) xor (W[1] shr 3)) + W[0];
t1:= h + (((e shr 6) or (e shl 26)) xor ((e shr 11) or (e shl 21)) xor
((e shr 25) or (e shl 7))) + ((e and f) xor (not e and g)) + $e49b69c1 + W[0];
t2:= (((a shr 2) or (a shl 30)) xor ((a shr 13) or (a shl 19)) xor
((a shr 22) xor (a shl 10))) + ((a and b) xor (a and c) xor (b and c));
h:= t1 + t2;
d:= d + t1;
W[1]:= (((W[15] shr 17) or (W[15] shl 15)) xor
((W[15] shr 19) or (W[15] shl 13)) xor (W[15] shr 10)) + W[10] +
(((W[2] shr 7) or (W[2] shl 25)) xor
((W[2] shr 18) or (W[2] shl 14)) xor (W[2] shr 3)) + W[1];
t1:= g + (((d shr 6) or (d shl 26)) xor ((d shr 11) or (d shl 21)) xor
((d shr 25) or (d shl 7))) + ((d and e) xor (not d and f)) + $efbe4786 + W[1];
t2:= (((h shr 2) or (h shl 30)) xor ((h shr 13) or (h shl 19)) xor
((h shr 22) xor (h shl 10))) + ((h and a) xor (h and b) xor (a and b));
g:= t1 + t2;
c:= c + t1;
W[2]:= (((W[0] shr 17) or (W[0] shl 15)) xor
((W[0] shr 19) or (W[0] shl 13)) xor (W[0] shr 10)) + W[11] +
(((W[3] shr 7) or (W[3] shl 25)) xor
((W[3] shr 18) or (W[3] shl 14)) xor (W[3] shr 3)) + W[2];
t1:= f + (((c shr 6) or (c shl 26)) xor ((c shr 11) or (c shl 21)) xor
((c shr 25) or (c shl 7))) + ((c and d) xor (not c and e)) + $0fc19dc6 + W[2];
t2:= (((g shr 2) or (g shl 30)) xor ((g shr 13) or (g shl 19)) xor
((g shr 22) xor (g shl 10))) + ((g and h) xor (g and a) xor (h and a));
f:= t1 + t2;
b:= b + t1;
W[3]:= (((W[1] shr 17) or (W[1] shl 15)) xor
((W[1] shr 19) or (W[1] shl 13)) xor (W[1] shr 10)) + W[12] +
(((W[4] shr 7) or (W[4] shl 25)) xor
((W[4] shr 18) or (W[4] shl 14)) xor (W[4] shr 3)) + W[3];
t1:= e + (((b shr 6) or (b shl 26)) xor ((b shr 11) or (b shl 21)) xor
((b shr 25) or (b shl 7))) + ((b and c) xor (not b and d)) + $240ca1cc + W[3];
t2:= (((f shr 2) or (f shl 30)) xor ((f shr 13) or (f shl 19)) xor
((f shr 22) xor (f shl 10))) + ((f and g) xor (f and h) xor (g and h));
e:= t1 + t2;
a:= a + t1;
W[4]:= (((W[2] shr 17) or (W[2] shl 15)) xor
((W[2] shr 19) or (W[2] shl 13)) xor (W[2] shr 10)) + W[13] +
(((W[5] shr 7) or (W[5] shl 25)) xor
((W[5] shr 18) or (W[5] shl 14)) xor (W[5] shr 3)) + W[4];
t1:= d + (((a shr 6) or (a shl 26)) xor ((a shr 11) or (a shl 21)) xor
((a shr 25) or (a shl 7))) + ((a and b) xor (not a and c)) + $2de92c6f + W[4];
t2:= (((e shr 2) or (e shl 30)) xor ((e shr 13) or (e shl 19)) xor
((e shr 22) xor (e shl 10))) + ((e and f) xor (e and g) xor (f and g));
d:= t1 + t2;
h:= h + t1;
W[5]:= (((W[3] shr 17) or (W[3] shl 15)) xor
((W[3] shr 19) or (W[3] shl 13)) xor (W[3] shr 10)) + W[14] +
(((W[6] shr 7) or (W[6] shl 25)) xor
((W[6] shr 18) or (W[6] shl 14)) xor (W[6] shr 3)) + W[5];
t1:= c + (((h shr 6) or (h shl 26)) xor ((h shr 11) or (h shl 21)) xor
((h shr 25) or (h shl 7))) + ((h and a) xor (not h and b)) + $4a7484aa + W[5];
t2:= (((d shr 2) or (d shl 30)) xor ((d shr 13) or (d shl 19)) xor
((d shr 22) xor (d shl 10))) + ((d and e) xor (d and f) xor (e and f));
c:= t1 + t2;
g:= g + t1;
W[6]:= (((W[4] shr 17) or (W[4] shl 15)) xor
((W[4] shr 19) or (W[4] shl 13)) xor (W[4] shr 10)) + W[15] +
(((W[7] shr 7) or (W[7] shl 25)) xor
((W[7] shr 18) or (W[7] shl 14)) xor (W[7] shr 3)) + W[6];
t1:= b + (((g shr 6) or (g shl 26)) xor ((g shr 11) or (g shl 21)) xor
((g shr 25) or (g shl 7))) + ((g and h) xor (not g and a)) + $5cb0a9dc + W[6];
t2:= (((c shr 2) or (c shl 30)) xor ((c shr 13) or (c shl 19)) xor
((c shr 22) xor (c shl 10))) + ((c and d) xor (c and e) xor (d and e));
b:= t1 + t2;
f:= f + t1;
W[7]:= (((W[5] shr 17) or (W[5] shl 15)) xor
((W[5] shr 19) or (W[5] shl 13)) xor (W[5] shr 10)) + W[0] +
(((W[8] shr 7) or (W[8] shl 25)) xor
((W[8] shr 18) or (W[8] shl 14)) xor (W[8] shr 3)) + W[7];
t1:= a + (((f shr 6) or (f shl 26)) xor ((f shr 11) or (f shl 21)) xor
((f shr 25) or (f shl 7))) + ((f and g) xor (not f and h)) + $76f988da + W[7];
t2:= (((b shr 2) or (b shl 30)) xor ((b shr 13) or (b shl 19)) xor
((b shr 22) xor (b shl 10))) + ((b and c) xor (b and d) xor (c and d));
a:= t1 + t2;
e:= e + t1;
W[8]:= (((W[6] shr 17) or (W[6] shl 15)) xor
((W[6] shr 19) or (W[6] shl 13)) xor (W[6] shr 10)) + W[1] +
(((W[9] shr 7) or (W[9] shl 25)) xor
((W[9] shr 18) or (W[9] shl 14)) xor (W[9] shr 3)) + W[8];
t1:= h + (((e shr 6) or (e shl 26)) xor ((e shr 11) or (e shl 21)) xor
((e shr 25) or (e shl 7))) + ((e and f) xor (not e and g)) + $983e5152 + W[8];
t2:= (((a shr 2) or (a shl 30)) xor ((a shr 13) or (a shl 19)) xor
((a shr 22) xor (a shl 10))) + ((a and b) xor (a and c) xor (b and c));
h:= t1 + t2;
d:= d + t1;
W[9]:= (((W[7] shr 17) or (W[7] shl 15)) xor
((W[7] shr 19) or (W[7] shl 13)) xor (W[7] shr 10)) + W[2] +
(((W[10] shr 7) or (W[10] shl 25)) xor
((W[10] shr 18) or (W[10] shl 14)) xor (W[10] shr 3)) + W[9];
t1:= g + (((d shr 6) or (d shl 26)) xor ((d shr 11) or (d shl 21)) xor
((d shr 25) or (d shl 7))) + ((d and e) xor (not d and f)) + $a831c66d + W[9];
t2:= (((h shr 2) or (h shl 30)) xor ((h shr 13) or (h shl 19)) xor
((h shr 22) xor (h shl 10))) + ((h and a) xor (h and b) xor (a and b));
g:= t1 + t2;
c:= c + t1;
W[10]:= (((W[8] shr 17) or (W[8] shl 15)) xor
((W[8] shr 19) or (W[8] shl 13)) xor (W[8] shr 10)) + W[3] +
(((W[11] shr 7) or (W[11] shl 25)) xor
((W[11] shr 18) or (W[11] shl 14)) xor (W[11] shr 3)) + W[10];
t1:= f + (((c shr 6) or (c shl 26)) xor ((c shr 11) or (c shl 21)) xor
((c shr 25) or (c shl 7))) + ((c and d) xor (not c and e)) + $b00327c8 + W[10];
t2:= (((g shr 2) or (g shl 30)) xor ((g shr 13) or (g shl 19)) xor
((g shr 22) xor (g shl 10))) + ((g and h) xor (g and a) xor (h and a));
f:= t1 + t2;
b:= b + t1;
W[11]:= (((W[9] shr 17) or (W[9] shl 15)) xor
((W[9] shr 19) or (W[9] shl 13)) xor (W[9] shr 10)) + W[4] +
(((W[12] shr 7) or (W[12] shl 25)) xor
((W[12] shr 18) or (W[12] shl 14)) xor (W[12] shr 3)) + W[11];
t1:= e + (((b shr 6) or (b shl 26)) xor ((b shr 11) or (b shl 21)) xor
((b shr 25) or (b shl 7))) + ((b and c) xor (not b and d)) + $bf597fc7 + W[11];
t2:= (((f shr 2) or (f shl 30)) xor ((f shr 13) or (f shl 19)) xor
((f shr 22) xor (f shl 10))) + ((f and g) xor (f and h) xor (g and h));
e:= t1 + t2;
a:= a + t1;
W[12]:= (((W[10] shr 17) or (W[10] shl 15)) xor
((W[10] shr 19) or (W[10] shl 13)) xor (W[10] shr 10)) + W[5] +
(((W[13] shr 7) or (W[13] shl 25)) xor
((W[13] shr 18) or (W[13] shl 14)) xor (W[13] shr 3)) + W[12];
t1:= d + (((a shr 6) or (a shl 26)) xor ((a shr 11) or (a shl 21)) xor
((a shr 25) or (a shl 7))) + ((a and b) xor (not a and c)) + $c6e00bf3 + W[12];
t2:= (((e shr 2) or (e shl 30)) xor ((e shr 13) or (e shl 19)) xor
((e shr 22) xor (e shl 10))) + ((e and f) xor (e and g) xor (f and g));
d:= t1 + t2;
h:= h + t1;
W[13]:= (((W[11] shr 17) or (W[11] shl 15)) xor
((W[11] shr 19) or (W[11] shl 13)) xor (W[11] shr 10)) + W[6] +
(((W[14] shr 7) or (W[14] shl 25)) xor
((W[14] shr 18) or (W[14] shl 14)) xor (W[14] shr 3)) + W[13];
t1:= c + (((h shr 6) or (h shl 26)) xor ((h shr 11) or (h shl 21)) xor
((h shr 25) or (h shl 7))) + ((h and a) xor (not h and b)) + $d5a79147 + W[13];
t2:= (((d shr 2) or (d shl 30)) xor ((d shr 13) or (d shl 19)) xor
((d shr 22) xor (d shl 10))) + ((d and e) xor (d and f) xor (e and f));
c:= t1 + t2;
g:= g + t1;
W[14]:= (((W[12] shr 17) or (W[12] shl 15)) xor
((W[12] shr 19) or (W[12] shl 13)) xor (W[12] shr 10)) + W[7] +
(((W[15] shr 7) or (W[15] shl 25)) xor
((W[15] shr 18) or (W[15] shl 14)) xor (W[15] shr 3)) + W[14];
t1:= b + (((g shr 6) or (g shl 26)) xor ((g shr 11) or (g shl 21)) xor
((g shr 25) or (g shl 7))) + ((g and h) xor (not g and a)) + $06ca6351 + W[14];
t2:= (((c shr 2) or (c shl 30)) xor ((c shr 13) or (c shl 19)) xor
((c shr 22) xor (c shl 10))) + ((c and d) xor (c and e) xor (d and e));
b:= t1 + t2;
f:= f + t1;
W[15]:= (((W[13] shr 17) or (W[13] shl 15)) xor
((W[13] shr 19) or (W[13] shl 13)) xor (W[13] shr 10)) + W[8] +
(((W[0] shr 7) or (W[0] shl 25)) xor
((W[0] shr 18) or (W[0] shl 14)) xor (W[0] shr 3)) + W[15];
t1:= a + (((f shr 6) or (f shl 26)) xor ((f shr 11) or (f shl 21)) xor
((f shr 25) or (f shl 7))) + ((f and g) xor (not f and h)) + $14292967 + W[15];
t2:= (((b shr 2) or (b shl 30)) xor ((b shr 13) or (b shl 19)) xor
((b shr 22) xor (b shl 10))) + ((b and c) xor (b and d) xor (c and d));
a:= t1 + t2;
e:= e + t1;
W[0]:= (((W[14] shr 17) or (W[14] shl 15)) xor
((W[14] shr 19) or (W[14] shl 13)) xor (W[14] shr 10)) + W[9] +
(((W[1] shr 7) or (W[1] shl 25)) xor
((W[1] shr 18) or (W[1] shl 14)) xor (W[1] shr 3)) + W[0];
t1:= h + (((e shr 6) or (e shl 26)) xor ((e shr 11) or (e shl 21)) xor
((e shr 25) or (e shl 7))) + ((e and f) xor (not e and g)) + $27b70a85 + W[0];
t2:= (((a shr 2) or (a shl 30)) xor ((a shr 13) or (a shl 19)) xor
((a shr 22) xor (a shl 10))) + ((a and b) xor (a and c) xor (b and c));
h:= t1 + t2;
d:= d + t1;
W[1]:= (((W[15] shr 17) or (W[15] shl 15)) xor
((W[15] shr 19) or (W[15] shl 13)) xor (W[15] shr 10)) + W[10] +
(((W[2] shr 7) or (W[2] shl 25)) xor
((W[2] shr 18) or (W[2] shl 14)) xor (W[2] shr 3)) + W[1];
t1:= g + (((d shr 6) or (d shl 26)) xor ((d shr 11) or (d shl 21)) xor
((d shr 25) or (d shl 7))) + ((d and e) xor (not d and f)) + $2e1b2138 + W[1];
t2:= (((h shr 2) or (h shl 30)) xor ((h shr 13) or (h shl 19)) xor
((h shr 22) xor (h shl 10))) + ((h and a) xor (h and b) xor (a and b));
g:= t1 + t2;
c:= c + t1;
W[2]:= (((W[0] shr 17) or (W[0] shl 15)) xor
((W[0] shr 19) or (W[0] shl 13)) xor (W[0] shr 10)) + W[11] +
(((W[3] shr 7) or (W[3] shl 25)) xor
((W[3] shr 18) or (W[3] shl 14)) xor (W[3] shr 3)) + W[2];
t1:= f + (((c shr 6) or (c shl 26)) xor ((c shr 11) or (c shl 21)) xor
((c shr 25) or (c shl 7))) + ((c and d) xor (not c and e)) + $4d2c6dfc + W[2];
t2:= (((g shr 2) or (g shl 30)) xor ((g shr 13) or (g shl 19)) xor
((g shr 22) xor (g shl 10))) + ((g and h) xor (g and a) xor (h and a));
f:= t1 + t2;
b:= b + t1;
W[3]:= (((W[1] shr 17) or (W[1] shl 15)) xor
((W[1] shr 19) or (W[1] shl 13)) xor (W[1] shr 10)) + W[12] +
(((W[4] shr 7) or (W[4] shl 25)) xor
((W[4] shr 18) or (W[4] shl 14)) xor (W[4] shr 3)) + W[3];
t1:= e + (((b shr 6) or (b shl 26)) xor ((b shr 11) or (b shl 21)) xor
((b shr 25) or (b shl 7))) + ((b and c) xor (not b and d)) + $53380d13 + W[3];
t2:= (((f shr 2) or (f shl 30)) xor ((f shr 13) or (f shl 19)) xor
((f shr 22) xor (f shl 10))) + ((f and g) xor (f and h) xor (g and h));
e:= t1 + t2;
a:= a + t1;
W[4]:= (((W[2] shr 17) or (W[2] shl 15)) xor
((W[2] shr 19) or (W[2] shl 13)) xor (W[2] shr 10)) + W[13] +
(((W[5] shr 7) or (W[5] shl 25)) xor
((W[5] shr 18) or (W[5] shl 14)) xor (W[5] shr 3)) + W[4];
t1:= d + (((a shr 6) or (a shl 26)) xor ((a shr 11) or (a shl 21)) xor
((a shr 25) or (a shl 7))) + ((a and b) xor (not a and c)) + $650a7354 + W[4];
t2:= (((e shr 2) or (e shl 30)) xor ((e shr 13) or (e shl 19)) xor
((e shr 22) xor (e shl 10))) + ((e and f) xor (e and g) xor (f and g));
d:= t1 + t2;
h:= h + t1;
W[5]:= (((W[3] shr 17) or (W[3] shl 15)) xor
((W[3] shr 19) or (W[3] shl 13)) xor (W[3] shr 10)) + W[14] +
(((W[6] shr 7) or (W[6] shl 25)) xor
((W[6] shr 18) or (W[6] shl 14)) xor (W[6] shr 3)) + W[5];
t1:= c + (((h shr 6) or (h shl 26)) xor ((h shr 11) or (h shl 21)) xor
((h shr 25) or (h shl 7))) + ((h and a) xor (not h and b)) + $766a0abb + W[5];
t2:= (((d shr 2) or (d shl 30)) xor ((d shr 13) or (d shl 19)) xor
((d shr 22) xor (d shl 10))) + ((d and e) xor (d and f) xor (e and f));
c:= t1 + t2;
g:= g + t1;
W[6]:= (((W[4] shr 17) or (W[4] shl 15)) xor
((W[4] shr 19) or (W[4] shl 13)) xor (W[4] shr 10)) + W[15] +
(((W[7] shr 7) or (W[7] shl 25)) xor
((W[7] shr 18) or (W[7] shl 14)) xor (W[7] shr 3)) + W[6];
t1:= b + (((g shr 6) or (g shl 26)) xor ((g shr 11) or (g shl 21)) xor
((g shr 25) or (g shl 7))) + ((g and h) xor (not g and a)) + $81c2c92e + W[6];
t2:= (((c shr 2) or (c shl 30)) xor ((c shr 13) or (c shl 19)) xor
((c shr 22) xor (c shl 10))) + ((c and d) xor (c and e) xor (d and e));
b:= t1 + t2;
f:= f + t1;
W[7]:= (((W[5] shr 17) or (W[5] shl 15)) xor
((W[5] shr 19) or (W[5] shl 13)) xor (W[5] shr 10)) + W[0] +
(((W[8] shr 7) or (W[8] shl 25)) xor
((W[8] shr 18) or (W[8] shl 14)) xor (W[8] shr 3)) + W[7];
t1:= a + (((f shr 6) or (f shl 26)) xor ((f shr 11) or (f shl 21)) xor
((f shr 25) or (f shl 7))) + ((f and g) xor (not f and h)) + $92722c85 + W[7];
t2:= (((b shr 2) or (b shl 30)) xor ((b shr 13) or (b shl 19)) xor
((b shr 22) xor (b shl 10))) + ((b and c) xor (b and d) xor (c and d));
a:= t1 + t2;
e:= e + t1;
W[8]:= (((W[6] shr 17) or (W[6] shl 15)) xor
((W[6] shr 19) or (W[6] shl 13)) xor (W[6] shr 10)) + W[1] +
(((W[9] shr 7) or (W[9] shl 25)) xor
((W[9] shr 18) or (W[9] shl 14)) xor (W[9] shr 3)) + W[8];
t1:= h + (((e shr 6) or (e shl 26)) xor ((e shr 11) or (e shl 21)) xor
((e shr 25) or (e shl 7))) + ((e and f) xor (not e and g)) + $a2bfe8a1 + W[8];
t2:= (((a shr 2) or (a shl 30)) xor ((a shr 13) or (a shl 19)) xor
((a shr 22) xor (a shl 10))) + ((a and b) xor (a and c) xor (b and c));
h:= t1 + t2;
d:= d + t1;
W[9]:= (((W[7] shr 17) or (W[7] shl 15)) xor
((W[7] shr 19) or (W[7] shl 13)) xor (W[7] shr 10)) + W[2] +
(((W[10] shr 7) or (W[10] shl 25)) xor
((W[10] shr 18) or (W[10] shl 14)) xor (W[10] shr 3)) + W[9];
t1:= g + (((d shr 6) or (d shl 26)) xor ((d shr 11) or (d shl 21)) xor
((d shr 25) or (d shl 7))) + ((d and e) xor (not d and f)) + $a81a664b + W[9];
t2:= (((h shr 2) or (h shl 30)) xor ((h shr 13) or (h shl 19)) xor
((h shr 22) xor (h shl 10))) + ((h and a) xor (h and b) xor (a and b));
g:= t1 + t2;
c:= c + t1;
W[10]:= (((W[8] shr 17) or (W[8] shl 15)) xor
((W[8] shr 19) or (W[8] shl 13)) xor (W[8] shr 10)) + W[3] +
(((W[11] shr 7) or (W[11] shl 25)) xor
((W[11] shr 18) or (W[11] shl 14)) xor (W[11] shr 3)) + W[10];
t1:= f + (((c shr 6) or (c shl 26)) xor ((c shr 11) or (c shl 21)) xor
((c shr 25) or (c shl 7))) + ((c and d) xor (not c and e)) + $c24b8b70 + W[10];
t2:= (((g shr 2) or (g shl 30)) xor ((g shr 13) or (g shl 19)) xor
((g shr 22) xor (g shl 10))) + ((g and h) xor (g and a) xor (h and a));
f:= t1 + t2;
b:= b + t1;
W[11]:= (((W[9] shr 17) or (W[9] shl 15)) xor
((W[9] shr 19) or (W[9] shl 13)) xor (W[9] shr 10)) + W[4] +
(((W[12] shr 7) or (W[12] shl 25)) xor
((W[12] shr 18) or (W[12] shl 14)) xor (W[12] shr 3)) + W[11];
t1:= e + (((b shr 6) or (b shl 26)) xor ((b shr 11) or (b shl 21)) xor
((b shr 25) or (b shl 7))) + ((b and c) xor (not b and d)) + $c76c51a3 + W[11];
t2:= (((f shr 2) or (f shl 30)) xor ((f shr 13) or (f shl 19)) xor
((f shr 22) xor (f shl 10))) + ((f and g) xor (f and h) xor (g and h));
e:= t1 + t2;
a:= a + t1;
W[12]:= (((W[10] shr 17) or (W[10] shl 15)) xor
((W[10] shr 19) or (W[10] shl 13)) xor (W[10] shr 10)) + W[5] +
(((W[13] shr 7) or (W[13] shl 25)) xor
((W[13] shr 18) or (W[13] shl 14)) xor (W[13] shr 3)) + W[12];
t1:= d + (((a shr 6) or (a shl 26)) xor ((a shr 11) or (a shl 21)) xor
((a shr 25) or (a shl 7))) + ((a and b) xor (not a and c)) + $d192e819 + W[12];
t2:= (((e shr 2) or (e shl 30)) xor ((e shr 13) or (e shl 19)) xor
((e shr 22) xor (e shl 10))) + ((e and f) xor (e and g) xor (f and g));
d:= t1 + t2;
h:= h + t1;
W[13]:= (((W[11] shr 17) or (W[11] shl 15)) xor
((W[11] shr 19) or (W[11] shl 13)) xor (W[11] shr 10)) + W[6] +
(((W[14] shr 7) or (W[14] shl 25)) xor
((W[14] shr 18) or (W[14] shl 14)) xor (W[14] shr 3)) + W[13];
t1:= c + (((h shr 6) or (h shl 26)) xor ((h shr 11) or (h shl 21)) xor
((h shr 25) or (h shl 7))) + ((h and a) xor (not h and b)) + $d6990624 + W[13];
t2:= (((d shr 2) or (d shl 30)) xor ((d shr 13) or (d shl 19)) xor
((d shr 22) xor (d shl 10))) + ((d and e) xor (d and f) xor (e and f));
c:= t1 + t2;
g:= g + t1;
W[14]:= (((W[12] shr 17) or (W[12] shl 15)) xor
((W[12] shr 19) or (W[12] shl 13)) xor (W[12] shr 10)) + W[7] +
(((W[15] shr 7) or (W[15] shl 25)) xor
((W[15] shr 18) or (W[15] shl 14)) xor (W[15] shr 3)) + W[14];
t1:= b + (((g shr 6) or (g shl 26)) xor ((g shr 11) or (g shl 21)) xor
((g shr 25) or (g shl 7))) + ((g and h) xor (not g and a)) + $f40e3585 + W[14];
t2:= (((c shr 2) or (c shl 30)) xor ((c shr 13) or (c shl 19)) xor
((c shr 22) xor (c shl 10))) + ((c and d) xor (c and e) xor (d and e));
b:= t1 + t2;
f:= f + t1;
W[15]:= (((W[13] shr 17) or (W[13] shl 15)) xor
((W[13] shr 19) or (W[13] shl 13)) xor (W[13] shr 10)) + W[8] +
(((W[0] shr 7) or (W[0] shl 25)) xor
((W[0] shr 18) or (W[0] shl 14)) xor (W[0] shr 3)) + W[15];
t1:= a + (((f shr 6) or (f shl 26)) xor ((f shr 11) or (f shl 21)) xor
((f shr 25) or (f shl 7))) + ((f and g) xor (not f and h)) + $106aa070 + W[15];
t2:= (((b shr 2) or (b shl 30)) xor ((b shr 13) or (b shl 19)) xor
((b shr 22) xor (b shl 10))) + ((b and c) xor (b and d) xor (c and d));
a:= t1 + t2;
e:= e + t1;
W[0]:= (((W[14] shr 17) or (W[14] shl 15)) xor
((W[14] shr 19) or (W[14] shl 13)) xor (W[14] shr 10)) + W[9] +
(((W[1] shr 7) or (W[1] shl 25)) xor
((W[1] shr 18) or (W[1] shl 14)) xor (W[1] shr 3)) + W[0];
t1:= h + (((e shr 6) or (e shl 26)) xor ((e shr 11) or (e shl 21)) xor
((e shr 25) or (e shl 7))) + ((e and f) xor (not e and g)) + $19a4c116 + W[0];
t2:= (((a shr 2) or (a shl 30)) xor ((a shr 13) or (a shl 19)) xor
((a shr 22) xor (a shl 10))) + ((a and b) xor (a and c) xor (b and c));
h:= t1 + t2;
d:= d + t1;
W[1]:= (((W[15] shr 17) or (W[15] shl 15)) xor
((W[15] shr 19) or (W[15] shl 13)) xor (W[15] shr 10)) + W[10] +
(((W[2] shr 7) or (W[2] shl 25)) xor
((W[2] shr 18) or (W[2] shl 14)) xor (W[2] shr 3)) + W[1];
t1:= g + (((d shr 6) or (d shl 26)) xor ((d shr 11) or (d shl 21)) xor
((d shr 25) or (d shl 7))) + ((d and e) xor (not d and f)) + $1e376c08 + W[1];
t2:= (((h shr 2) or (h shl 30)) xor ((h shr 13) or (h shl 19)) xor
((h shr 22) xor (h shl 10))) + ((h and a) xor (h and b) xor (a and b));
g:= t1 + t2;
c:= c + t1;
W[2]:= (((W[0] shr 17) or (W[0] shl 15)) xor
((W[0] shr 19) or (W[0] shl 13)) xor (W[0] shr 10)) + W[11] +
(((W[3] shr 7) or (W[3] shl 25)) xor
((W[3] shr 18) or (W[3] shl 14)) xor (W[3] shr 3)) + W[2];
t1:= f + (((c shr 6) or (c shl 26)) xor ((c shr 11) or (c shl 21)) xor
((c shr 25) or (c shl 7))) + ((c and d) xor (not c and e)) + $2748774c + W[2];
t2:= (((g shr 2) or (g shl 30)) xor ((g shr 13) or (g shl 19)) xor
((g shr 22) xor (g shl 10))) + ((g and h) xor (g and a) xor (h and a));
f:= t1 + t2;
b:= b + t1;
W[3]:= (((W[1] shr 17) or (W[1] shl 15)) xor
((W[1] shr 19) or (W[1] shl 13)) xor (W[1] shr 10)) + W[12] +
(((W[4] shr 7) or (W[4] shl 25)) xor
((W[4] shr 18) or (W[4] shl 14)) xor (W[4] shr 3)) + W[3];
t1:= e + (((b shr 6) or (b shl 26)) xor ((b shr 11) or (b shl 21)) xor
((b shr 25) or (b shl 7))) + ((b and c) xor (not b and d)) + $34b0bcb5 + W[3];
t2:= (((f shr 2) or (f shl 30)) xor ((f shr 13) or (f shl 19)) xor
((f shr 22) xor (f shl 10))) + ((f and g) xor (f and h) xor (g and h));
e:= t1 + t2;
a:= a + t1;
W[4]:= (((W[2] shr 17) or (W[2] shl 15)) xor
((W[2] shr 19) or (W[2] shl 13)) xor (W[2] shr 10)) + W[13] +
(((W[5] shr 7) or (W[5] shl 25)) xor
((W[5] shr 18) or (W[5] shl 14)) xor (W[5] shr 3)) + W[4];
t1:= d + (((a shr 6) or (a shl 26)) xor ((a shr 11) or (a shl 21)) xor
((a shr 25) or (a shl 7))) + ((a and b) xor (not a and c)) + $391c0cb3 + W[4];
t2:= (((e shr 2) or (e shl 30)) xor ((e shr 13) or (e shl 19)) xor
((e shr 22) xor (e shl 10))) + ((e and f) xor (e and g) xor (f and g));
d:= t1 + t2;
h:= h + t1;
W[5]:= (((W[3] shr 17) or (W[3] shl 15)) xor
((W[3] shr 19) or (W[3] shl 13)) xor (W[3] shr 10)) + W[14] +
(((W[6] shr 7) or (W[6] shl 25)) xor
((W[6] shr 18) or (W[6] shl 14)) xor (W[6] shr 3)) + W[5];
t1:= c + (((h shr 6) or (h shl 26)) xor ((h shr 11) or (h shl 21)) xor
((h shr 25) or (h shl 7))) + ((h and a) xor (not h and b)) + $4ed8aa4a + W[5];
t2:= (((d shr 2) or (d shl 30)) xor ((d shr 13) or (d shl 19)) xor
((d shr 22) xor (d shl 10))) + ((d and e) xor (d and f) xor (e and f));
c:= t1 + t2;
g:= g + t1;
W[6]:= (((W[4] shr 17) or (W[4] shl 15)) xor
((W[4] shr 19) or (W[4] shl 13)) xor (W[4] shr 10)) + W[15] +
(((W[7] shr 7) or (W[7] shl 25)) xor
((W[7] shr 18) or (W[7] shl 14)) xor (W[7] shr 3)) + W[6];
t1:= b + (((g shr 6) or (g shl 26)) xor ((g shr 11) or (g shl 21)) xor
((g shr 25) or (g shl 7))) + ((g and h) xor (not g and a)) + $5b9cca4f + W[6];
t2:= (((c shr 2) or (c shl 30)) xor ((c shr 13) or (c shl 19)) xor
((c shr 22) xor (c shl 10))) + ((c and d) xor (c and e) xor (d and e));
b:= t1 + t2;
f:= f + t1;
W[7]:= (((W[5] shr 17) or (W[5] shl 15)) xor
((W[5] shr 19) or (W[5] shl 13)) xor (W[5] shr 10)) + W[0] +
(((W[8] shr 7) or (W[8] shl 25)) xor
((W[8] shr 18) or (W[8] shl 14)) xor (W[8] shr 3)) + W[7];
t1:= a + (((f shr 6) or (f shl 26)) xor ((f shr 11) or (f shl 21)) xor
((f shr 25) or (f shl 7))) + ((f and g) xor (not f and h)) + $682e6ff3 + W[7];
t2:= (((b shr 2) or (b shl 30)) xor ((b shr 13) or (b shl 19)) xor
((b shr 22) xor (b shl 10))) + ((b and c) xor (b and d) xor (c and d));
a:= t1 + t2;
e:= e + t1;
W[8]:= (((W[6] shr 17) or (W[6] shl 15)) xor
((W[6] shr 19) or (W[6] shl 13)) xor (W[6] shr 10)) + W[1] +
(((W[9] shr 7) or (W[9] shl 25)) xor
((W[9] shr 18) or (W[9] shl 14)) xor (W[9] shr 3)) + W[8];
t1:= h + (((e shr 6) or (e shl 26)) xor ((e shr 11) or (e shl 21)) xor
((e shr 25) or (e shl 7))) + ((e and f) xor (not e and g)) + $748f82ee + W[8];
t2:= (((a shr 2) or (a shl 30)) xor ((a shr 13) or (a shl 19)) xor
((a shr 22) xor (a shl 10))) + ((a and b) xor (a and c) xor (b and c));
h:= t1 + t2;
d:= d + t1;
W[9]:= (((W[7] shr 17) or (W[7] shl 15)) xor
((W[7] shr 19) or (W[7] shl 13)) xor (W[7] shr 10)) + W[2] +
(((W[10] shr 7) or (W[10] shl 25)) xor
((W[10] shr 18) or (W[10] shl 14)) xor (W[10] shr 3)) + W[9];
t1:= g + (((d shr 6) or (d shl 26)) xor ((d shr 11) or (d shl 21)) xor
((d shr 25) or (d shl 7))) + ((d and e) xor (not d and f)) + $78a5636f + W[9];
t2:= (((h shr 2) or (h shl 30)) xor ((h shr 13) or (h shl 19)) xor
((h shr 22) xor (h shl 10))) + ((h and a) xor (h and b) xor (a and b));
g:= t1 + t2;
c:= c + t1;
W[10]:= (((W[8] shr 17) or (W[8] shl 15)) xor
((W[8] shr 19) or (W[8] shl 13)) xor (W[8] shr 10)) + W[3] +
(((W[11] shr 7) or (W[11] shl 25)) xor
((W[11] shr 18) or (W[11] shl 14)) xor (W[11] shr 3)) + W[10];
t1:= f + (((c shr 6) or (c shl 26)) xor ((c shr 11) or (c shl 21)) xor
((c shr 25) or (c shl 7))) + ((c and d) xor (not c and e)) + $84c87814 + W[10];
t2:= (((g shr 2) or (g shl 30)) xor ((g shr 13) or (g shl 19)) xor
((g shr 22) xor (g shl 10))) + ((g and h) xor (g and a) xor (h and a));
f:= t1 + t2;
b:= b + t1;
W[11]:= (((W[9] shr 17) or (W[9] shl 15)) xor
((W[9] shr 19) or (W[9] shl 13)) xor (W[9] shr 10)) + W[4] +
(((W[12] shr 7) or (W[12] shl 25)) xor
((W[12] shr 18) or (W[12] shl 14)) xor (W[12] shr 3)) + W[11];
t1:= e + (((b shr 6) or (b shl 26)) xor ((b shr 11) or (b shl 21)) xor
((b shr 25) or (b shl 7))) + ((b and c) xor (not b and d)) + $8cc70208 + W[11];
t2:= (((f shr 2) or (f shl 30)) xor ((f shr 13) or (f shl 19)) xor
((f shr 22) xor (f shl 10))) + ((f and g) xor (f and h) xor (g and h));
e:= t1 + t2;
a:= a + t1;
W[12]:= (((W[10] shr 17) or (W[10] shl 15)) xor
((W[10] shr 19) or (W[10] shl 13)) xor (W[10] shr 10)) + W[5] +
(((W[13] shr 7) or (W[13] shl 25)) xor
((W[13] shr 18) or (W[13] shl 14)) xor (W[13] shr 3)) + W[12];
t1:= d + (((a shr 6) or (a shl 26)) xor ((a shr 11) or (a shl 21)) xor
((a shr 25) or (a shl 7))) + ((a and b) xor (not a and c)) + $90befffa + W[12];
t2:= (((e shr 2) or (e shl 30)) xor ((e shr 13) or (e shl 19)) xor
((e shr 22) xor (e shl 10))) + ((e and f) xor (e and g) xor (f and g));
d:= t1 + t2;
h:= h + t1;
W[13]:= (((W[11] shr 17) or (W[11] shl 15)) xor
((W[11] shr 19) or (W[11] shl 13)) xor (W[11] shr 10)) + W[6] +
(((W[14] shr 7) or (W[14] shl 25)) xor
((W[14] shr 18) or (W[14] shl 14)) xor (W[14] shr 3)) + W[13];
t1:= c + (((h shr 6) or (h shl 26)) xor ((h shr 11) or (h shl 21)) xor
((h shr 25) or (h shl 7))) + ((h and a) xor (not h and b)) + $a4506ceb + W[13];
t2:= (((d shr 2) or (d shl 30)) xor ((d shr 13) or (d shl 19)) xor
((d shr 22) xor (d shl 10))) + ((d and e) xor (d and f) xor (e and f));
c:= t1 + t2;
g:= g + t1;
W[14]:= (((W[12] shr 17) or (W[12] shl 15)) xor
((W[12] shr 19) or (W[12] shl 13)) xor (W[12] shr 10)) + W[7] +
(((W[15] shr 7) or (W[15] shl 25)) xor
((W[15] shr 18) or (W[15] shl 14)) xor (W[15] shr 3)) + W[14];
t1:= b + (((g shr 6) or (g shl 26)) xor ((g shr 11) or (g shl 21)) xor
((g shr 25) or (g shl 7))) + ((g and h) xor (not g and a)) + $bef9a3f7 + W[14];
t2:= (((c shr 2) or (c shl 30)) xor ((c shr 13) or (c shl 19)) xor
((c shr 22) xor (c shl 10))) + ((c and d) xor (c and e) xor (d and e));
b:= t1 + t2;
f:= f + t1;
W[15]:= (((W[13] shr 17) or (W[13] shl 15)) xor
((W[13] shr 19) or (W[13] shl 13)) xor (W[13] shr 10)) + W[8] +
(((W[0] shr 7) or (W[0] shl 25)) xor
((W[0] shr 18) or (W[0] shl 14)) xor (W[0] shr 3)) + W[15];
t1:= a + (((f shr 6) or (f shl 26)) xor ((f shr 11) or (f shl 21)) xor
((f shr 25) or (f shl 7))) + ((f and g) xor (not f and h)) + $c67178f2 + W[15];
t2:= (((b shr 2) or (b shl 30)) xor ((b shr 13) or (b shl 19)) xor
((b shr 22) xor (b shl 10))) + ((b and c) xor (b and d) xor (c and d));
a:= t1 + t2;
e:= e + t1;
FData.Digest[0]:= FData.Digest[0] + a;
FData.Digest[1]:= FData.Digest[1] + b;
FData.Digest[2]:= FData.Digest[2] + c;
FData.Digest[3]:= FData.Digest[3] + d;
FData.Digest[4]:= FData.Digest[4] + e;
FData.Digest[5]:= FData.Digest[5] + f;
FData.Digest[6]:= FData.Digest[6] + g;
FData.Digest[7]:= FData.Digest[7] + h;
// FillChar(W, SizeOf(W), 0);
FillChar(FData.Block, SizeOf(FData.Block), 0);
end;
{$ENDIF}
{$ENDIF}
{$IFDEF CPUX86_WIN32}
procedure TSHA256Alg.Compress;
const
// SHA256 registers:
DigestA = -32; // [EDI - 32]
DigestB = -28; // [EDI - 28]
DigestC = -24; // [EDI - 24]
DigestD = -20; // [EDI - 20]
DigestE = -16; // [EDI - 16]
DigestF = -12; // [EDI - 12]
DigestG = -8; // [EDI - 8]
DigestH = -4; // [EDI - 4]
RegA = 28; // [ESP + 28]
RegB = 24; // [ESP + 24]
RegC = 20; // [ESP + 20]
RegD = 16; // [ESP + 16]
RegE = 12; // [ESP + 12]
RegF = 8; // [ESP + 8]
RegG = 4; // [ESP + 4]
RegH = 0; // [ESP]
W0 = 0; W1 = 4; W2 = 8; W3 = 12;
W4 = 16; W5 = 20; W6 = 24; W7 = 28;
W8 = 32; W9 = 36; W10 = 40; W11 = 44;
W12 = 48; W13 = 52; W14 = 56; W15 = 60;
asm
PUSH ESI
PUSH EDI
PUSH EBX
PUSH EBP
LEA EDI,[EAX].TSHA256Alg.FData.Block // W:= @FData.Block;
PUSH [EDI].DigestA
PUSH [EDI].DigestB
PUSH [EDI].DigestC
PUSH [EDI].DigestD
PUSH [EDI].DigestE
PUSH [EDI].DigestF
PUSH [EDI].DigestG
PUSH [EDI].DigestH
{
SUB ESP,32
MOV EAX,[EDI].DigestA
MOV [ESP].RegA,EAX
MOV EAX,[EDI].DigestB
MOV [ESP].RegB,EAX
MOV EAX,[EDI].DigestC
MOV [ESP].RegC,EAX
MOV EAX,[EDI].DigestD
MOV [ESP].RegD,EAX
MOV EAX,[EDI].DigestE
MOV [ESP].RegE,EAX
MOV EAX,[EDI].DigestF
MOV [ESP].RegF,EAX
MOV EAX,[EDI].DigestG
MOV [ESP].RegG,EAX
MOV EAX,[EDI].DigestH
MOV [ESP].RegH,EAX
}
// W[0]:= Swap32(W[0]);
MOV ESI,[EDI].W0
BSWAP ESI
MOV [EDI].W0,ESI
// t1:= h + (((e shr 6) or (e shl 26)) xor ((e shr 11) or (e shl 21)) xor
// ((e shr 25) or (e shl 7))) + ((e and f) xor (not e and g)) + $428a2f98 + W[0];
MOV EAX,[ESP].RegE
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegF
NOT EAX
AND EAX,[ESP].RegG
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$428a2f98
ADD EBX,[ESP].RegH
// t2:= (((a shr 2) or (a shl 30)) xor ((a shr 13) or (a shl 19)) xor
// ((a shr 22) xor (a shl 10))) + ((a and b) xor (a and c) xor (b and c));
MOV EAX,[ESP].RegA
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegB
MOV EBP,[ESP].RegC
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// h:= t1 + t2;
// d:= d + t1;
ADD [ESP].RegD,EBX
ADD EAX,EBX
MOV [ESP].RegH,EAX
// W[1]:= Swap32(W[1]);
MOV ESI,[EDI].W1
BSWAP ESI
MOV [EDI].W1,ESI
// t1:= g + (((d shr 6) or (d shl 26)) xor ((d shr 11) or (d shl 21)) xor
// ((d shr 25) or (d shl 7))) + ((d and e) xor (not d and f)) + $71374491 + W[1];
MOV EAX,[ESP].RegD
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegE
NOT EAX
AND EAX,[ESP].RegF
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$71374491
ADD EBX,[ESP].RegG
// t2:= (((h shr 2) or (h shl 30)) xor ((h shr 13) or (h shl 19)) xor
// ((h shr 22) xor (h shl 10))) + ((h and a) xor (h and b) xor (a and b));
MOV EAX,[ESP].RegH
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegA
MOV EBP,[ESP].RegB
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// g:= t1 + t2;
// c:= c + t1;
ADD [ESP].RegC,EBX
ADD EAX,EBX
MOV [ESP].RegG,EAX
// W[2]:= Swap32(W[2]);
MOV ESI,[EDI].W2
BSWAP ESI
MOV [EDI].W2,ESI
// t1:= f + (((c shr 6) or (c shl 26)) xor ((c shr 11) or (c shl 21)) xor
// ((c shr 25) or (c shl 7))) + ((c and d) xor (not c and e)) + $b5c0fbcf + W[2];
MOV EAX,[ESP].RegC
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegD
NOT EAX
AND EAX,[ESP].RegE
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$b5c0fbcf
ADD EBX,[ESP].RegF
// t2:= (((g shr 2) or (g shl 30)) xor ((g shr 13) or (g shl 19)) xor
// ((g shr 22) xor (g shl 10))) + ((g and h) xor (g and a) xor (h and a));
MOV EAX,[ESP].RegG
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegH
MOV EBP,[ESP].RegA
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// f:= t1 + t2;
// b:= b + t1;
ADD [ESP].RegB,EBX
ADD EAX,EBX
MOV [ESP].RegF,EAX
// W[3]:= Swap32(W[3]);
MOV ESI,[EDI].W3
BSWAP ESI
MOV [EDI].W3,ESI
// t1:= e + (((b shr 6) or (b shl 26)) xor ((b shr 11) or (b shl 21)) xor
// ((b shr 25) or (b shl 7))) + ((b and c) xor (not b and d)) + $e9b5dba5 + W[3];
MOV EAX,[ESP].RegB
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegC
NOT EAX
AND EAX,[ESP].RegD
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$e9b5dba5
ADD EBX,[ESP].RegE
// t2:= (((f shr 2) or (f shl 30)) xor ((f shr 13) or (f shl 19)) xor
// ((f shr 22) xor (f shl 10))) + ((f and g) xor (f and h) xor (g and h));
MOV EAX,[ESP].RegF
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegG
MOV EBP,[ESP].RegH
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// e:= t1 + t2;
// a:= a + t1;
ADD [ESP].RegA,EBX
ADD EAX,EBX
MOV [ESP].RegE,EAX
// W[4]:= Swap32(W[4]);
MOV ESI,[EDI].W4
BSWAP ESI
MOV [EDI].W4,ESI
// t1:= d + (((a shr 6) or (a shl 26)) xor ((a shr 11) or (a shl 21)) xor
// ((a shr 25) or (a shl 7))) + ((a and b) xor (not a and c)) + $3956c25b + W[4];
MOV EAX,[ESP].RegA
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegB
NOT EAX
AND EAX,[ESP].RegC
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$3956c25b
ADD EBX,[ESP].RegD
// t2:= (((e shr 2) or (e shl 30)) xor ((e shr 13) or (e shl 19)) xor
// ((e shr 22) xor (e shl 10))) + ((e and f) xor (e and g) xor (f and g));
MOV EAX,[ESP].RegE
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegF
MOV EBP,[ESP].RegG
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// d:= t1 + t2;
// h:= h + t1;
ADD [ESP].RegH,EBX
ADD EAX,EBX
MOV [ESP].RegD,EAX
// W[5]:= Swap32(W[5]);
MOV ESI,[EDI].W5
BSWAP ESI
MOV [EDI].W5,ESI
// t1:= c + (((h shr 6) or (h shl 26)) xor ((h shr 11) or (h shl 21)) xor
// ((h shr 25) or (h shl 7))) + ((h and a) xor (not h and b)) + $59f111f1 + W[5];
MOV EAX,[ESP].RegH
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegA
NOT EAX
AND EAX,[ESP].RegB
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$59f111f1
ADD EBX,[ESP].RegC
// t2:= (((d shr 2) or (d shl 30)) xor ((d shr 13) or (d shl 19)) xor
// ((d shr 22) xor (d shl 10))) + ((d and e) xor (d and f) xor (e and f));
MOV EAX,[ESP].RegD
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegE
MOV EBP,[ESP].RegF
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// c:= t1 + t2;
// g:= g + t1;
ADD [ESP].RegG,EBX
ADD EAX,EBX
MOV [ESP].RegC,EAX
// W[6]:= Swap32(W[6]);
MOV ESI,[EDI].W6
BSWAP ESI
MOV [EDI].W6,ESI
// t1:= b + (((g shr 6) or (g shl 26)) xor ((g shr 11) or (g shl 21)) xor
// ((g shr 25) or (g shl 7))) + ((g and h) xor (not g and a)) + $923f82a4 + W[6];
MOV EAX,[ESP].RegG
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegH
NOT EAX
AND EAX,[ESP].RegA
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$923f82a4
ADD EBX,[ESP].RegB
// t2:= (((c shr 2) or (c shl 30)) xor ((c shr 13) or (c shl 19)) xor
// ((c shr 22) xor (c shl 10))) + ((c and d) xor (c and e) xor (d and e));
MOV EAX,[ESP].RegC
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegD
MOV EBP,[ESP].RegE
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// b:= t1 + t2;
// f:= f + t1;
ADD [ESP].RegF,EBX
ADD EAX,EBX
MOV [ESP].RegB,EAX
// W[7]:= Swap32(W[7]);
MOV ESI,[EDI].W7
BSWAP ESI
MOV [EDI].W7,ESI
// t1:= a + (((f shr 6) or (f shl 26)) xor ((f shr 11) or (f shl 21)) xor
// ((f shr 25) or (f shl 7))) + ((f and g) xor (not f and h)) + $ab1c5ed5 + W[7];
MOV EAX,[ESP].RegF
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegG
NOT EAX
AND EAX,[ESP].RegH
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$ab1c5ed5
ADD EBX,[ESP].RegA
// t2:= (((b shr 2) or (b shl 30)) xor ((b shr 13) or (b shl 19)) xor
// ((b shr 22) xor (b shl 10))) + ((b and c) xor (b and d) xor (c and d));
MOV EAX,[ESP].RegB
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegC
MOV EBP,[ESP].RegD
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// a:= t1 + t2;
// e:= e + t1;
ADD [ESP].RegE,EBX
ADD EAX,EBX
MOV [ESP].RegA,EAX
// W[8]:= Swap32(W[8]);
MOV ESI,[EDI].W8
BSWAP ESI
MOV [EDI].W8,ESI
// t1:= h + (((e shr 6) or (e shl 26)) xor ((e shr 11) or (e shl 21)) xor
// ((e shr 25) or (e shl 7))) + ((e and f) xor (not e and g)) + $d807aa98 + W[8];
MOV EAX,[ESP].RegE
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegF
NOT EAX
AND EAX,[ESP].RegG
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$d807aa98
ADD EBX,[ESP].RegH
// t2:= (((a shr 2) or (a shl 30)) xor ((a shr 13) or (a shl 19)) xor
// ((a shr 22) xor (a shl 10))) + ((a and b) xor (a and c) xor (b and c));
MOV EAX,[ESP].RegA
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegB
MOV EBP,[ESP].RegC
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// h:= t1 + t2;
// d:= d + t1;
ADD [ESP].RegD,EBX
ADD EAX,EBX
MOV [ESP].RegH,EAX
// W[9]:= Swap32(W[9]);
MOV ESI,[EDI].W9
BSWAP ESI
MOV [EDI].W9,ESI
// t1:= g + (((d shr 6) or (d shl 26)) xor ((d shr 11) or (d shl 21)) xor
// ((d shr 25) or (d shl 7))) + ((d and e) xor (not d and f)) + $12835b01 + W[9];
MOV EAX,[ESP].RegD
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegE
NOT EAX
AND EAX,[ESP].RegF
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$12835b01
ADD EBX,[ESP].RegG
// t2:= (((h shr 2) or (h shl 30)) xor ((h shr 13) or (h shl 19)) xor
// ((h shr 22) xor (h shl 10))) + ((h and a) xor (h and b) xor (a and b));
MOV EAX,[ESP].RegH
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegA
MOV EBP,[ESP].RegB
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// g:= t1 + t2;
// c:= c + t1;
ADD [ESP].RegC,EBX
ADD EAX,EBX
MOV [ESP].RegG,EAX
// W[10]:= Swap32(W[10]);
MOV ESI,[EDI].W10
BSWAP ESI
MOV [EDI].W10,ESI
// t1:= f + (((c shr 6) or (c shl 26)) xor ((c shr 11) or (c shl 21)) xor
// ((c shr 25) or (c shl 7))) + ((c and d) xor (not c and e)) + $243185be + W[10];
MOV EAX,[ESP].RegC
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegD
NOT EAX
AND EAX,[ESP].RegE
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$243185be
ADD EBX,[ESP].RegF
// t2:= (((g shr 2) or (g shl 30)) xor ((g shr 13) or (g shl 19)) xor
// ((g shr 22) xor (g shl 10))) + ((g and h) xor (g and a) xor (h and a));
MOV EAX,[ESP].RegG
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegH
MOV EBP,[ESP].RegA
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// f:= t1 + t2;
// b:= b + t1;
ADD [ESP].RegB,EBX
ADD EAX,EBX
MOV [ESP].RegF,EAX
// W[11]:= Swap32(W[11]);
MOV ESI,[EDI].W11
BSWAP ESI
MOV [EDI].W11,ESI
// t1:= e + (((b shr 6) or (b shl 26)) xor ((b shr 11) or (b shl 21)) xor
// ((b shr 25) or (b shl 7))) + ((b and c) xor (not b and d)) + $550c7dc3 + W[11];
MOV EAX,[ESP].RegB
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegC
NOT EAX
AND EAX,[ESP].RegD
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$550c7dc3
ADD EBX,[ESP].RegE
// t2:= (((f shr 2) or (f shl 30)) xor ((f shr 13) or (f shl 19)) xor
// ((f shr 22) xor (f shl 10))) + ((f and g) xor (f and h) xor (g and h));
MOV EAX,[ESP].RegF
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegG
MOV EBP,[ESP].RegH
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// e:= t1 + t2;
// a:= a + t1;
ADD [ESP].RegA,EBX
ADD EAX,EBX
MOV [ESP].RegE,EAX
// W[12]:= Swap32(W[12]);
MOV ESI,[EDI].W12
BSWAP ESI
MOV [EDI].W12,ESI
// t1:= d + (((a shr 6) or (a shl 26)) xor ((a shr 11) or (a shl 21)) xor
// ((a shr 25) or (a shl 7))) + ((a and b) xor (not a and c)) + $72be5d74 + W[12];
MOV EAX,[ESP].RegA
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegB
NOT EAX
AND EAX,[ESP].RegC
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$72be5d74
ADD EBX,[ESP].RegD
// t2:= (((e shr 2) or (e shl 30)) xor ((e shr 13) or (e shl 19)) xor
// ((e shr 22) xor (e shl 10))) + ((e and f) xor (e and g) xor (f and g));
MOV EAX,[ESP].RegE
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegF
MOV EBP,[ESP].RegG
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// d:= t1 + t2;
// h:= h + t1;
ADD [ESP].RegH,EBX
ADD EAX,EBX
MOV [ESP].RegD,EAX
// W[13]:= Swap32(W[13]);
MOV ESI,[EDI].W13
BSWAP ESI
MOV [EDI].W13,ESI
// t1:= c + (((h shr 6) or (h shl 26)) xor ((h shr 11) or (h shl 21)) xor
// ((h shr 25) or (h shl 7))) + ((h and a) xor (not h and b)) + $80deb1fe + W[13];
MOV EAX,[ESP].RegH
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegA
NOT EAX
AND EAX,[ESP].RegB
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$80deb1fe
ADD EBX,[ESP].RegC
// t2:= (((d shr 2) or (d shl 30)) xor ((d shr 13) or (d shl 19)) xor
// ((d shr 22) xor (d shl 10))) + ((d and e) xor (d and f) xor (e and f));
MOV EAX,[ESP].RegD
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegE
MOV EBP,[ESP].RegF
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// c:= t1 + t2;
// g:= g + t1;
ADD [ESP].RegG,EBX
ADD EAX,EBX
MOV [ESP].RegC,EAX
// W[14]:= Swap32(W[14]);
MOV ESI,[EDI].W14
BSWAP ESI
MOV [EDI].W14,ESI
// t1:= b + (((g shr 6) or (g shl 26)) xor ((g shr 11) or (g shl 21)) xor
// ((g shr 25) or (g shl 7))) + ((g and h) xor (not g and a)) + $9bdc06a7 + W[14];
MOV EAX,[ESP].RegG
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegH
NOT EAX
AND EAX,[ESP].RegA
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$9bdc06a7
ADD EBX,[ESP].RegB
// t2:= (((c shr 2) or (c shl 30)) xor ((c shr 13) or (c shl 19)) xor
// ((c shr 22) xor (c shl 10))) + ((c and d) xor (c and e) xor (d and e));
MOV EAX,[ESP].RegC
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegD
MOV EBP,[ESP].RegE
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// b:= t1 + t2;
// f:= f + t1;
ADD [ESP].RegF,EBX
ADD EAX,EBX
MOV [ESP].RegB,EAX
// W[15]:= Swap32(W[15]);
MOV ESI,[EDI].W15
BSWAP ESI
MOV [EDI].W15,ESI
// t1:= a + (((f shr 6) or (f shl 26)) xor ((f shr 11) or (f shl 21)) xor
// ((f shr 25) or (f shl 7))) + ((f and g) xor (not f and h)) + $c19bf174 + W[15];
MOV EAX,[ESP].RegF
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegG
NOT EAX
AND EAX,[ESP].RegH
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$c19bf174
ADD EBX,[ESP].RegA
// t2:= (((b shr 2) or (b shl 30)) xor ((b shr 13) or (b shl 19)) xor
// ((b shr 22) xor (b shl 10))) + ((b and c) xor (b and d) xor (c and d));
MOV EAX,[ESP].RegB
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegC
MOV EBP,[ESP].RegD
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// a:= t1 + t2;
// e:= e + t1;
ADD [ESP].RegE,EBX
ADD EAX,EBX
MOV [ESP].RegA,EAX
// W[0]:= (((W[14] shr 17) or (W[14] shl 15)) xor
// ((W[14] shr 19) or (W[14] shl 13)) xor (W[14] shr 10)) + W[9] +
// (((W[1] shr 7) or (W[1] shl 25)) xor
// ((W[1] shr 18) or (W[1] shl 14)) xor (W[1] shr 3)) + W[0];
MOV ESI,[EDI].W14
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W1
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W9
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W0
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W0,ESI
// t1:= h + (((e shr 6) or (e shl 26)) xor ((e shr 11) or (e shl 21)) xor
// ((e shr 25) or (e shl 7))) + ((e and f) xor (not e and g)) + $e49b69c1 + W[0];
MOV EAX,[ESP].RegE
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegF
NOT EAX
AND EAX,[ESP].RegG
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$e49b69c1
ADD EBX,[ESP].RegH
// t2:= (((a shr 2) or (a shl 30)) xor ((a shr 13) or (a shl 19)) xor
// ((a shr 22) xor (a shl 10))) + ((a and b) xor (a and c) xor (b and c));
MOV EAX,[ESP].RegA
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegB
MOV EBP,[ESP].RegC
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// h:= t1 + t2;
// d:= d + t1;
ADD [ESP].RegD,EBX
ADD EAX,EBX
MOV [ESP].RegH,EAX
// W[1]:= (((W[15] shr 17) or (W[15] shl 15)) xor
// ((W[15] shr 19) or (W[15] shl 13)) xor (W[15] shr 10)) + W[10] +
// (((W[2] shr 7) or (W[2] shl 25)) xor
// ((W[2] shr 18) or (W[2] shl 14)) xor (W[2] shr 3)) + W[1];
MOV ESI,[EDI].W15
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W2
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W10
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W1
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W1,ESI
// t1:= g + (((d shr 6) or (d shl 26)) xor ((d shr 11) or (d shl 21)) xor
// ((d shr 25) or (d shl 7))) + ((d and e) xor (not d and f)) + $efbe4786 + W[1];
MOV EAX,[ESP].RegD
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegE
NOT EAX
AND EAX,[ESP].RegF
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$efbe4786
ADD EBX,[ESP].RegG
// t2:= (((h shr 2) or (h shl 30)) xor ((h shr 13) or (h shl 19)) xor
// ((h shr 22) xor (h shl 10))) + ((h and a) xor (h and b) xor (a and b));
MOV EAX,[ESP].RegH
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegA
MOV EBP,[ESP].RegB
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// g:= t1 + t2;
// c:= c + t1;
ADD [ESP].RegC,EBX
ADD EAX,EBX
MOV [ESP].RegG,EAX
// W[2]:= (((W[0] shr 17) or (W[0] shl 15)) xor
// ((W[0] shr 19) or (W[0] shl 13)) xor (W[0] shr 10)) + W[11] +
// (((W[3] shr 7) or (W[3] shl 25)) xor
// ((W[3] shr 18) or (W[3] shl 14)) xor (W[3] shr 3)) + W[2];
MOV ESI,[EDI].W0
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W3
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W11
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W2
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W2,ESI
// t1:= f + (((c shr 6) or (c shl 26)) xor ((c shr 11) or (c shl 21)) xor
// ((c shr 25) or (c shl 7))) + ((c and d) xor (not c and e)) + $0fc19dc6 + W[2];
MOV EAX,[ESP].RegC
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegD
NOT EAX
AND EAX,[ESP].RegE
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$0fc19dc6
ADD EBX,[ESP].RegF
// t2:= (((g shr 2) or (g shl 30)) xor ((g shr 13) or (g shl 19)) xor
// ((g shr 22) xor (g shl 10))) + ((g and h) xor (g and a) xor (h and a));
MOV EAX,[ESP].RegG
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegH
MOV EBP,[ESP].RegA
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// f:= t1 + t2;
// b:= b + t1;
ADD [ESP].RegB,EBX
ADD EAX,EBX
MOV [ESP].RegF,EAX
// W[3]:= (((W[1] shr 17) or (W[1] shl 15)) xor
// ((W[1] shr 19) or (W[1] shl 13)) xor (W[1] shr 10)) + W[12] +
// (((W[4] shr 7) or (W[4] shl 25)) xor
// ((W[4] shr 18) or (W[4] shl 14)) xor (W[4] shr 3)) + W[3];
MOV ESI,[EDI].W1
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W4
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W12
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W3
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W3,ESI
// t1:= e + (((b shr 6) or (b shl 26)) xor ((b shr 11) or (b shl 21)) xor
// ((b shr 25) or (b shl 7))) + ((b and c) xor (not b and d)) + $240ca1cc + W[3];
MOV EAX,[ESP].RegB
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegC
NOT EAX
AND EAX,[ESP].RegD
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$240ca1cc
ADD EBX,[ESP].RegE
// t2:= (((f shr 2) or (f shl 30)) xor ((f shr 13) or (f shl 19)) xor
// ((f shr 22) xor (f shl 10))) + ((f and g) xor (f and h) xor (g and h));
MOV EAX,[ESP].RegF
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegG
MOV EBP,[ESP].RegH
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// e:= t1 + t2;
// a:= a + t1;
ADD [ESP].RegA,EBX
ADD EAX,EBX
MOV [ESP].RegE,EAX
// W[4]:= (((W[2] shr 17) or (W[2] shl 15)) xor
// ((W[2] shr 19) or (W[2] shl 13)) xor (W[2] shr 10)) + W[13] +
// (((W[5] shr 7) or (W[5] shl 25)) xor
// ((W[5] shr 18) or (W[5] shl 14)) xor (W[5] shr 3)) + W[4];
MOV ESI,[EDI].W2
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W5
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W13
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W4
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W4,ESI
// t1:= d + (((a shr 6) or (a shl 26)) xor ((a shr 11) or (a shl 21)) xor
// ((a shr 25) or (a shl 7))) + ((a and b) xor (not a and c)) + $2de92c6f + W[4];
MOV EAX,[ESP].RegA
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegB
NOT EAX
AND EAX,[ESP].RegC
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$2de92c6f
ADD EBX,[ESP].RegD
// t2:= (((e shr 2) or (e shl 30)) xor ((e shr 13) or (e shl 19)) xor
// ((e shr 22) xor (e shl 10))) + ((e and f) xor (e and g) xor (f and g));
MOV EAX,[ESP].RegE
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegF
MOV EBP,[ESP].RegG
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// d:= t1 + t2;
// h:= h + t1;
ADD [ESP].RegH,EBX
ADD EAX,EBX
MOV [ESP].RegD,EAX
// W[5]:= (((W[3] shr 17) or (W[3] shl 15)) xor
// ((W[3] shr 19) or (W[3] shl 13)) xor (W[3] shr 10)) + W[14] +
// (((W[6] shr 7) or (W[6] shl 25)) xor
// ((W[6] shr 18) or (W[6] shl 14)) xor (W[6] shr 3)) + W[5];
MOV ESI,[EDI].W3
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W6
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W14
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W5
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W5,ESI
// t1:= c + (((h shr 6) or (h shl 26)) xor ((h shr 11) or (h shl 21)) xor
// ((h shr 25) or (h shl 7))) + ((h and a) xor (not h and b)) + $4a7484aa + W[5];
MOV EAX,[ESP].RegH
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegA
NOT EAX
AND EAX,[ESP].RegB
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$4a7484aa
ADD EBX,[ESP].RegC
// t2:= (((d shr 2) or (d shl 30)) xor ((d shr 13) or (d shl 19)) xor
// ((d shr 22) xor (d shl 10))) + ((d and e) xor (d and f) xor (e and f));
MOV EAX,[ESP].RegD
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegE
MOV EBP,[ESP].RegF
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// c:= t1 + t2;
// g:= g + t1;
ADD [ESP].RegG,EBX
ADD EAX,EBX
MOV [ESP].RegC,EAX
// W[6]:= (((W[4] shr 17) or (W[4] shl 15)) xor
// ((W[4] shr 19) or (W[4] shl 13)) xor (W[4] shr 10)) + W[15] +
// (((W[7] shr 7) or (W[7] shl 25)) xor
// ((W[7] shr 18) or (W[7] shl 14)) xor (W[7] shr 3)) + W[6];
MOV ESI,[EDI].W4
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W7
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W15
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W6
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W6,ESI
// t1:= b + (((g shr 6) or (g shl 26)) xor ((g shr 11) or (g shl 21)) xor
// ((g shr 25) or (g shl 7))) + ((g and h) xor (not g and a)) + $5cb0a9dc + W[6];
MOV EAX,[ESP].RegG
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegH
NOT EAX
AND EAX,[ESP].RegA
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$5cb0a9dc
ADD EBX,[ESP].RegB
// t2:= (((c shr 2) or (c shl 30)) xor ((c shr 13) or (c shl 19)) xor
// ((c shr 22) xor (c shl 10))) + ((c and d) xor (c and e) xor (d and e));
MOV EAX,[ESP].RegC
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegD
MOV EBP,[ESP].RegE
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// b:= t1 + t2;
// f:= f + t1;
ADD [ESP].RegF,EBX
ADD EAX,EBX
MOV [ESP].RegB,EAX
// W[7]:= (((W[5] shr 17) or (W[5] shl 15)) xor
// ((W[5] shr 19) or (W[5] shl 13)) xor (W[5] shr 10)) + W[0] +
// (((W[8] shr 7) or (W[8] shl 25)) xor
// ((W[8] shr 18) or (W[8] shl 14)) xor (W[8] shr 3)) + W[7];
MOV ESI,[EDI].W5
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W8
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W0
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W7
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W7,ESI
// t1:= a + (((f shr 6) or (f shl 26)) xor ((f shr 11) or (f shl 21)) xor
// ((f shr 25) or (f shl 7))) + ((f and g) xor (not f and h)) + $76f988da + W[7];
MOV EAX,[ESP].RegF
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegG
NOT EAX
AND EAX,[ESP].RegH
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$76f988da
ADD EBX,[ESP].RegA
// t2:= (((b shr 2) or (b shl 30)) xor ((b shr 13) or (b shl 19)) xor
// ((b shr 22) xor (b shl 10))) + ((b and c) xor (b and d) xor (c and d));
MOV EAX,[ESP].RegB
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegC
MOV EBP,[ESP].RegD
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// a:= t1 + t2;
// e:= e + t1;
ADD [ESP].RegE,EBX
ADD EAX,EBX
MOV [ESP].RegA,EAX
// W[8]:= (((W[6] shr 17) or (W[6] shl 15)) xor
// ((W[6] shr 19) or (W[6] shl 13)) xor (W[6] shr 10)) + W[1] +
// (((W[9] shr 7) or (W[9] shl 25)) xor
// ((W[9] shr 18) or (W[9] shl 14)) xor (W[9] shr 3)) + W[8];
MOV ESI,[EDI].W6
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W9
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W1
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W8
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W8,ESI
// t1:= h + (((e shr 6) or (e shl 26)) xor ((e shr 11) or (e shl 21)) xor
// ((e shr 25) or (e shl 7))) + ((e and f) xor (not e and g)) + $983e5152 + W[8];
MOV EAX,[ESP].RegE
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegF
NOT EAX
AND EAX,[ESP].RegG
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$983e5152
ADD EBX,[ESP].RegH
// t2:= (((a shr 2) or (a shl 30)) xor ((a shr 13) or (a shl 19)) xor
// ((a shr 22) xor (a shl 10))) + ((a and b) xor (a and c) xor (b and c));
MOV EAX,[ESP].RegA
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegB
MOV EBP,[ESP].RegC
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// h:= t1 + t2;
// d:= d + t1;
ADD [ESP].RegD,EBX
ADD EAX,EBX
MOV [ESP].RegH,EAX
// W[9]:= (((W[7] shr 17) or (W[7] shl 15)) xor
// ((W[7] shr 19) or (W[7] shl 13)) xor (W[7] shr 10)) + W[2] +
// (((W[10] shr 7) or (W[10] shl 25)) xor
// ((W[10] shr 18) or (W[10] shl 14)) xor (W[10] shr 3)) + W[9];
MOV ESI,[EDI].W7
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W10
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W2
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W9
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W9,ESI
// t1:= g + (((d shr 6) or (d shl 26)) xor ((d shr 11) or (d shl 21)) xor
// ((d shr 25) or (d shl 7))) + ((d and e) xor (not d and f)) + $a831c66d + W[9];
MOV EAX,[ESP].RegD
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegE
NOT EAX
AND EAX,[ESP].RegF
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$a831c66d
ADD EBX,[ESP].RegG
// t2:= (((h shr 2) or (h shl 30)) xor ((h shr 13) or (h shl 19)) xor
// ((h shr 22) xor (h shl 10))) + ((h and a) xor (h and b) xor (a and b));
MOV EAX,[ESP].RegH
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegA
MOV EBP,[ESP].RegB
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// g:= t1 + t2;
// c:= c + t1;
ADD [ESP].RegC,EBX
ADD EAX,EBX
MOV [ESP].RegG,EAX
// W[10]:= (((W[8] shr 17) or (W[8] shl 15)) xor
// ((W[8] shr 19) or (W[8] shl 13)) xor (W[8] shr 10)) + W[3] +
// (((W[11] shr 7) or (W[11] shl 25)) xor
// ((W[11] shr 18) or (W[11] shl 14)) xor (W[11] shr 3)) + W[10];
MOV ESI,[EDI].W8
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W11
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W3
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W10
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W10,ESI
// t1:= f + (((c shr 6) or (c shl 26)) xor ((c shr 11) or (c shl 21)) xor
// ((c shr 25) or (c shl 7))) + ((c and d) xor (not c and e)) + $b00327c8 + W[10];
MOV EAX,[ESP].RegC
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegD
NOT EAX
AND EAX,[ESP].RegE
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$b00327c8
ADD EBX,[ESP].RegF
// t2:= (((g shr 2) or (g shl 30)) xor ((g shr 13) or (g shl 19)) xor
// ((g shr 22) xor (g shl 10))) + ((g and h) xor (g and a) xor (h and a));
MOV EAX,[ESP].RegG
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegH
MOV EBP,[ESP].RegA
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// f:= t1 + t2;
// b:= b + t1;
ADD [ESP].RegB,EBX
ADD EAX,EBX
MOV [ESP].RegF,EAX
// W[11]:= (((W[9] shr 17) or (W[9] shl 15)) xor
// ((W[9] shr 19) or (W[9] shl 13)) xor (W[9] shr 10)) + W[4] +
// (((W[12] shr 7) or (W[12] shl 25)) xor
// ((W[12] shr 18) or (W[12] shl 14)) xor (W[12] shr 3)) + W[11];
MOV ESI,[EDI].W9
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W12
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W4
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W11
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W11,ESI
// t1:= e + (((b shr 6) or (b shl 26)) xor ((b shr 11) or (b shl 21)) xor
// ((b shr 25) or (b shl 7))) + ((b and c) xor (not b and d)) + $bf597fc7 + W[11];
MOV EAX,[ESP].RegB
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegC
NOT EAX
AND EAX,[ESP].RegD
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$bf597fc7
ADD EBX,[ESP].RegE
// t2:= (((f shr 2) or (f shl 30)) xor ((f shr 13) or (f shl 19)) xor
// ((f shr 22) xor (f shl 10))) + ((f and g) xor (f and h) xor (g and h));
MOV EAX,[ESP].RegF
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegG
MOV EBP,[ESP].RegH
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// e:= t1 + t2;
// a:= a + t1;
ADD [ESP].RegA,EBX
ADD EAX,EBX
MOV [ESP].RegE,EAX
// W[12]:= (((W[10] shr 17) or (W[10] shl 15)) xor
// ((W[10] shr 19) or (W[10] shl 13)) xor (W[10] shr 10)) + W[5] +
// (((W[13] shr 7) or (W[13] shl 25)) xor
// ((W[13] shr 18) or (W[13] shl 14)) xor (W[13] shr 3)) + W[12];
MOV ESI,[EDI].W10
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W13
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W5
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W12
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W12,ESI
// t1:= d + (((a shr 6) or (a shl 26)) xor ((a shr 11) or (a shl 21)) xor
// ((a shr 25) or (a shl 7))) + ((a and b) xor (not a and c)) + $c6e00bf3 + W[12];
MOV EAX,[ESP].RegA
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegB
NOT EAX
AND EAX,[ESP].RegC
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$c6e00bf3
ADD EBX,[ESP].RegD
// t2:= (((e shr 2) or (e shl 30)) xor ((e shr 13) or (e shl 19)) xor
// ((e shr 22) xor (e shl 10))) + ((e and f) xor (e and g) xor (f and g));
MOV EAX,[ESP].RegE
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegF
MOV EBP,[ESP].RegG
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// d:= t1 + t2;
// h:= h + t1;
ADD [ESP].RegH,EBX
ADD EAX,EBX
MOV [ESP].RegD,EAX
// W[13]:= (((W[11] shr 17) or (W[11] shl 15)) xor
// ((W[11] shr 19) or (W[11] shl 13)) xor (W[11] shr 10)) + W[6] +
// (((W[14] shr 7) or (W[14] shl 25)) xor
// ((W[14] shr 18) or (W[14] shl 14)) xor (W[14] shr 3)) + W[13];
MOV ESI,[EDI].W11
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W14
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W6
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W13
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W13,ESI
// t1:= c + (((h shr 6) or (h shl 26)) xor ((h shr 11) or (h shl 21)) xor
// ((h shr 25) or (h shl 7))) + ((h and a) xor (not h and b)) + $d5a79147 + W[13];
MOV EAX,[ESP].RegH
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegA
NOT EAX
AND EAX,[ESP].RegB
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$d5a79147
ADD EBX,[ESP].RegC
// t2:= (((d shr 2) or (d shl 30)) xor ((d shr 13) or (d shl 19)) xor
// ((d shr 22) xor (d shl 10))) + ((d and e) xor (d and f) xor (e and f));
MOV EAX,[ESP].RegD
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegE
MOV EBP,[ESP].RegF
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// c:= t1 + t2;
// g:= g + t1;
ADD [ESP].RegG,EBX
ADD EAX,EBX
MOV [ESP].RegC,EAX
// W[14]:= (((W[12] shr 17) or (W[12] shl 15)) xor
// ((W[12] shr 19) or (W[12] shl 13)) xor (W[12] shr 10)) + W[7] +
// (((W[15] shr 7) or (W[15] shl 25)) xor
// ((W[15] shr 18) or (W[15] shl 14)) xor (W[15] shr 3)) + W[14];
MOV ESI,[EDI].W12
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W15
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W7
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W14
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W14,ESI
// t1:= b + (((g shr 6) or (g shl 26)) xor ((g shr 11) or (g shl 21)) xor
// ((g shr 25) or (g shl 7))) + ((g and h) xor (not g and a)) + $06ca6351 + W[14];
MOV EAX,[ESP].RegG
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegH
NOT EAX
AND EAX,[ESP].RegA
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$06ca6351
ADD EBX,[ESP].RegB
// t2:= (((c shr 2) or (c shl 30)) xor ((c shr 13) or (c shl 19)) xor
// ((c shr 22) xor (c shl 10))) + ((c and d) xor (c and e) xor (d and e));
MOV EAX,[ESP].RegC
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegD
MOV EBP,[ESP].RegE
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// b:= t1 + t2;
// f:= f + t1;
ADD [ESP].RegF,EBX
ADD EAX,EBX
MOV [ESP].RegB,EAX
// W[15]:= (((W[13] shr 17) or (W[13] shl 15)) xor
// ((W[13] shr 19) or (W[13] shl 13)) xor (W[13] shr 10)) + W[8] +
// (((W[0] shr 7) or (W[0] shl 25)) xor
// ((W[0] shr 18) or (W[0] shl 14)) xor (W[0] shr 3)) + W[15];
MOV ESI,[EDI].W13
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W0
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W8
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W15
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W15,ESI
// t1:= a + (((f shr 6) or (f shl 26)) xor ((f shr 11) or (f shl 21)) xor
// ((f shr 25) or (f shl 7))) + ((f and g) xor (not f and h)) + $14292967 + W[15];
MOV EAX,[ESP].RegF
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegG
NOT EAX
AND EAX,[ESP].RegH
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$14292967
ADD EBX,[ESP].RegA
// t2:= (((b shr 2) or (b shl 30)) xor ((b shr 13) or (b shl 19)) xor
// ((b shr 22) xor (b shl 10))) + ((b and c) xor (b and d) xor (c and d));
MOV EAX,[ESP].RegB
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegC
MOV EBP,[ESP].RegD
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// a:= t1 + t2;
// e:= e + t1;
ADD [ESP].RegE,EBX
ADD EAX,EBX
MOV [ESP].RegA,EAX
// W[0]:= (((W[14] shr 17) or (W[14] shl 15)) xor
// ((W[14] shr 19) or (W[14] shl 13)) xor (W[14] shr 10)) + W[9] +
// (((W[1] shr 7) or (W[1] shl 25)) xor
// ((W[1] shr 18) or (W[1] shl 14)) xor (W[1] shr 3)) + W[0];
MOV ESI,[EDI].W14
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W1
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W9
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W0
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W0,ESI
// t1:= h + (((e shr 6) or (e shl 26)) xor ((e shr 11) or (e shl 21)) xor
// ((e shr 25) or (e shl 7))) + ((e and f) xor (not e and g)) + $27b70a85 + W[0];
MOV EAX,[ESP].RegE
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegF
NOT EAX
AND EAX,[ESP].RegG
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$27b70a85
ADD EBX,[ESP].RegH
// t2:= (((a shr 2) or (a shl 30)) xor ((a shr 13) or (a shl 19)) xor
// ((a shr 22) xor (a shl 10))) + ((a and b) xor (a and c) xor (b and c));
MOV EAX,[ESP].RegA
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegB
MOV EBP,[ESP].RegC
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// h:= t1 + t2;
// d:= d + t1;
ADD [ESP].RegD,EBX
ADD EAX,EBX
MOV [ESP].RegH,EAX
// W[1]:= (((W[15] shr 17) or (W[15] shl 15)) xor
// ((W[15] shr 19) or (W[15] shl 13)) xor (W[15] shr 10)) + W[10] +
// (((W[2] shr 7) or (W[2] shl 25)) xor
// ((W[2] shr 18) or (W[2] shl 14)) xor (W[2] shr 3)) + W[1];
MOV ESI,[EDI].W15
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W2
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W10
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W1
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W1,ESI
// t1:= g + (((d shr 6) or (d shl 26)) xor ((d shr 11) or (d shl 21)) xor
// ((d shr 25) or (d shl 7))) + ((d and e) xor (not d and f)) + $2e1b2138 + W[1];
MOV EAX,[ESP].RegD
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegE
NOT EAX
AND EAX,[ESP].RegF
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$2e1b2138
ADD EBX,[ESP].RegG
// t2:= (((h shr 2) or (h shl 30)) xor ((h shr 13) or (h shl 19)) xor
// ((h shr 22) xor (h shl 10))) + ((h and a) xor (h and b) xor (a and b));
MOV EAX,[ESP].RegH
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegA
MOV EBP,[ESP].RegB
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// g:= t1 + t2;
// c:= c + t1;
ADD [ESP].RegC,EBX
ADD EAX,EBX
MOV [ESP].RegG,EAX
// W[2]:= (((W[0] shr 17) or (W[0] shl 15)) xor
// ((W[0] shr 19) or (W[0] shl 13)) xor (W[0] shr 10)) + W[11] +
// (((W[3] shr 7) or (W[3] shl 25)) xor
// ((W[3] shr 18) or (W[3] shl 14)) xor (W[3] shr 3)) + W[2];
MOV ESI,[EDI].W0
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W3
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W11
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W2
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W2,ESI
// t1:= f + (((c shr 6) or (c shl 26)) xor ((c shr 11) or (c shl 21)) xor
// ((c shr 25) or (c shl 7))) + ((c and d) xor (not c and e)) + $4d2c6dfc + W[2];
MOV EAX,[ESP].RegC
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegD
NOT EAX
AND EAX,[ESP].RegE
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$4d2c6dfc
ADD EBX,[ESP].RegF
// t2:= (((g shr 2) or (g shl 30)) xor ((g shr 13) or (g shl 19)) xor
// ((g shr 22) xor (g shl 10))) + ((g and h) xor (g and a) xor (h and a));
MOV EAX,[ESP].RegG
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegH
MOV EBP,[ESP].RegA
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// f:= t1 + t2;
// b:= b + t1;
ADD [ESP].RegB,EBX
ADD EAX,EBX
MOV [ESP].RegF,EAX
// W[3]:= (((W[1] shr 17) or (W[1] shl 15)) xor
// ((W[1] shr 19) or (W[1] shl 13)) xor (W[1] shr 10)) + W[12] +
// (((W[4] shr 7) or (W[4] shl 25)) xor
// ((W[4] shr 18) or (W[4] shl 14)) xor (W[4] shr 3)) + W[3];
MOV ESI,[EDI].W1
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W4
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W12
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W3
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W3,ESI
// t1:= e + (((b shr 6) or (b shl 26)) xor ((b shr 11) or (b shl 21)) xor
// ((b shr 25) or (b shl 7))) + ((b and c) xor (not b and d)) + $53380d13 + W[3];
MOV EAX,[ESP].RegB
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegC
NOT EAX
AND EAX,[ESP].RegD
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$53380d13
ADD EBX,[ESP].RegE
// t2:= (((f shr 2) or (f shl 30)) xor ((f shr 13) or (f shl 19)) xor
// ((f shr 22) xor (f shl 10))) + ((f and g) xor (f and h) xor (g and h));
MOV EAX,[ESP].RegF
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegG
MOV EBP,[ESP].RegH
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// e:= t1 + t2;
// a:= a + t1;
ADD [ESP].RegA,EBX
ADD EAX,EBX
MOV [ESP].RegE,EAX
// W[4]:= (((W[2] shr 17) or (W[2] shl 15)) xor
// ((W[2] shr 19) or (W[2] shl 13)) xor (W[2] shr 10)) + W[13] +
// (((W[5] shr 7) or (W[5] shl 25)) xor
// ((W[5] shr 18) or (W[5] shl 14)) xor (W[5] shr 3)) + W[4];
MOV ESI,[EDI].W2
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W5
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W13
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W4
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W4,ESI
// t1:= d + (((a shr 6) or (a shl 26)) xor ((a shr 11) or (a shl 21)) xor
// ((a shr 25) or (a shl 7))) + ((a and b) xor (not a and c)) + $650a7354 + W[4];
MOV EAX,[ESP].RegA
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegB
NOT EAX
AND EAX,[ESP].RegC
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$650a7354
ADD EBX,[ESP].RegD
// t2:= (((e shr 2) or (e shl 30)) xor ((e shr 13) or (e shl 19)) xor
// ((e shr 22) xor (e shl 10))) + ((e and f) xor (e and g) xor (f and g));
MOV EAX,[ESP].RegE
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegF
MOV EBP,[ESP].RegG
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// d:= t1 + t2;
// h:= h + t1;
ADD [ESP].RegH,EBX
ADD EAX,EBX
MOV [ESP].RegD,EAX
// W[5]:= (((W[3] shr 17) or (W[3] shl 15)) xor
// ((W[3] shr 19) or (W[3] shl 13)) xor (W[3] shr 10)) + W[14] +
// (((W[6] shr 7) or (W[6] shl 25)) xor
// ((W[6] shr 18) or (W[6] shl 14)) xor (W[6] shr 3)) + W[5];
MOV ESI,[EDI].W3
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W6
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W14
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W5
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W5,ESI
// t1:= c + (((h shr 6) or (h shl 26)) xor ((h shr 11) or (h shl 21)) xor
// ((h shr 25) or (h shl 7))) + ((h and a) xor (not h and b)) + $766a0abb + W[5];
MOV EAX,[ESP].RegH
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegA
NOT EAX
AND EAX,[ESP].RegB
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$766a0abb
ADD EBX,[ESP].RegC
// t2:= (((d shr 2) or (d shl 30)) xor ((d shr 13) or (d shl 19)) xor
// ((d shr 22) xor (d shl 10))) + ((d and e) xor (d and f) xor (e and f));
MOV EAX,[ESP].RegD
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegE
MOV EBP,[ESP].RegF
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// c:= t1 + t2;
// g:= g + t1;
ADD [ESP].RegG,EBX
ADD EAX,EBX
MOV [ESP].RegC,EAX
// W[6]:= (((W[4] shr 17) or (W[4] shl 15)) xor
// ((W[4] shr 19) or (W[4] shl 13)) xor (W[4] shr 10)) + W[15] +
// (((W[7] shr 7) or (W[7] shl 25)) xor
// ((W[7] shr 18) or (W[7] shl 14)) xor (W[7] shr 3)) + W[6];
MOV ESI,[EDI].W4
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W7
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W15
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W6
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W6,ESI
// t1:= b + (((g shr 6) or (g shl 26)) xor ((g shr 11) or (g shl 21)) xor
// ((g shr 25) or (g shl 7))) + ((g and h) xor (not g and a)) + $81c2c92e + W[6];
MOV EAX,[ESP].RegG
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegH
NOT EAX
AND EAX,[ESP].RegA
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$81c2c92e
ADD EBX,[ESP].RegB
// t2:= (((c shr 2) or (c shl 30)) xor ((c shr 13) or (c shl 19)) xor
// ((c shr 22) xor (c shl 10))) + ((c and d) xor (c and e) xor (d and e));
MOV EAX,[ESP].RegC
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegD
MOV EBP,[ESP].RegE
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// b:= t1 + t2;
// f:= f + t1;
ADD [ESP].RegF,EBX
ADD EAX,EBX
MOV [ESP].RegB,EAX
// W[7]:= (((W[5] shr 17) or (W[5] shl 15)) xor
// ((W[5] shr 19) or (W[5] shl 13)) xor (W[5] shr 10)) + W[0] +
// (((W[8] shr 7) or (W[8] shl 25)) xor
// ((W[8] shr 18) or (W[8] shl 14)) xor (W[8] shr 3)) + W[7];
MOV ESI,[EDI].W5
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W8
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W0
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W7
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W7,ESI
// t1:= a + (((f shr 6) or (f shl 26)) xor ((f shr 11) or (f shl 21)) xor
// ((f shr 25) or (f shl 7))) + ((f and g) xor (not f and h)) + $92722c85 + W[7];
MOV EAX,[ESP].RegF
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegG
NOT EAX
AND EAX,[ESP].RegH
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$92722c85
ADD EBX,[ESP].RegA
// t2:= (((b shr 2) or (b shl 30)) xor ((b shr 13) or (b shl 19)) xor
// ((b shr 22) xor (b shl 10))) + ((b and c) xor (b and d) xor (c and d));
MOV EAX,[ESP].RegB
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegC
MOV EBP,[ESP].RegD
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// a:= t1 + t2;
// e:= e + t1;
ADD [ESP].RegE,EBX
ADD EAX,EBX
MOV [ESP].RegA,EAX
// W[8]:= (((W[6] shr 17) or (W[6] shl 15)) xor
// ((W[6] shr 19) or (W[6] shl 13)) xor (W[6] shr 10)) + W[1] +
// (((W[9] shr 7) or (W[9] shl 25)) xor
// ((W[9] shr 18) or (W[9] shl 14)) xor (W[9] shr 3)) + W[8];
MOV ESI,[EDI].W6
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W9
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W1
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W8
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W8,ESI
// t1:= h + (((e shr 6) or (e shl 26)) xor ((e shr 11) or (e shl 21)) xor
// ((e shr 25) or (e shl 7))) + ((e and f) xor (not e and g)) + $a2bfe8a1 + W[8];
MOV EAX,[ESP].RegE
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegF
NOT EAX
AND EAX,[ESP].RegG
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$a2bfe8a1
ADD EBX,[ESP].RegH
// t2:= (((a shr 2) or (a shl 30)) xor ((a shr 13) or (a shl 19)) xor
// ((a shr 22) xor (a shl 10))) + ((a and b) xor (a and c) xor (b and c));
MOV EAX,[ESP].RegA
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegB
MOV EBP,[ESP].RegC
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// h:= t1 + t2;
// d:= d + t1;
ADD [ESP].RegD,EBX
ADD EAX,EBX
MOV [ESP].RegH,EAX
// W[9]:= (((W[7] shr 17) or (W[7] shl 15)) xor
// ((W[7] shr 19) or (W[7] shl 13)) xor (W[7] shr 10)) + W[2] +
// (((W[10] shr 7) or (W[10] shl 25)) xor
// ((W[10] shr 18) or (W[10] shl 14)) xor (W[10] shr 3)) + W[9];
MOV ESI,[EDI].W7
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W10
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W2
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W9
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W9,ESI
// t1:= g + (((d shr 6) or (d shl 26)) xor ((d shr 11) or (d shl 21)) xor
// ((d shr 25) or (d shl 7))) + ((d and e) xor (not d and f)) + $a81a664b + W[9];
MOV EAX,[ESP].RegD
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegE
NOT EAX
AND EAX,[ESP].RegF
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$a81a664b
ADD EBX,[ESP].RegG
// t2:= (((h shr 2) or (h shl 30)) xor ((h shr 13) or (h shl 19)) xor
// ((h shr 22) xor (h shl 10))) + ((h and a) xor (h and b) xor (a and b));
MOV EAX,[ESP].RegH
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegA
MOV EBP,[ESP].RegB
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// g:= t1 + t2;
// c:= c + t1;
ADD [ESP].RegC,EBX
ADD EAX,EBX
MOV [ESP].RegG,EAX
// W[10]:= (((W[8] shr 17) or (W[8] shl 15)) xor
// ((W[8] shr 19) or (W[8] shl 13)) xor (W[8] shr 10)) + W[3] +
// (((W[11] shr 7) or (W[11] shl 25)) xor
// ((W[11] shr 18) or (W[11] shl 14)) xor (W[11] shr 3)) + W[10];
MOV ESI,[EDI].W8
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W11
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W3
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W10
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W10,ESI
// t1:= f + (((c shr 6) or (c shl 26)) xor ((c shr 11) or (c shl 21)) xor
// ((c shr 25) or (c shl 7))) + ((c and d) xor (not c and e)) + $c24b8b70 + W[10];
MOV EAX,[ESP].RegC
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegD
NOT EAX
AND EAX,[ESP].RegE
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$c24b8b70
ADD EBX,[ESP].RegF
// t2:= (((g shr 2) or (g shl 30)) xor ((g shr 13) or (g shl 19)) xor
// ((g shr 22) xor (g shl 10))) + ((g and h) xor (g and a) xor (h and a));
MOV EAX,[ESP].RegG
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegH
MOV EBP,[ESP].RegA
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// f:= t1 + t2;
// b:= b + t1;
ADD [ESP].RegB,EBX
ADD EAX,EBX
MOV [ESP].RegF,EAX
// W[11]:= (((W[9] shr 17) or (W[9] shl 15)) xor
// ((W[9] shr 19) or (W[9] shl 13)) xor (W[9] shr 10)) + W[4] +
// (((W[12] shr 7) or (W[12] shl 25)) xor
// ((W[12] shr 18) or (W[12] shl 14)) xor (W[12] shr 3)) + W[11];
MOV ESI,[EDI].W9
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W12
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W4
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W11
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W11,ESI
// t1:= e + (((b shr 6) or (b shl 26)) xor ((b shr 11) or (b shl 21)) xor
// ((b shr 25) or (b shl 7))) + ((b and c) xor (not b and d)) + $c76c51a3 + W[11];
MOV EAX,[ESP].RegB
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegC
NOT EAX
AND EAX,[ESP].RegD
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$c76c51a3
ADD EBX,[ESP].RegE
// t2:= (((f shr 2) or (f shl 30)) xor ((f shr 13) or (f shl 19)) xor
// ((f shr 22) xor (f shl 10))) + ((f and g) xor (f and h) xor (g and h));
MOV EAX,[ESP].RegF
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegG
MOV EBP,[ESP].RegH
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// e:= t1 + t2;
// a:= a + t1;
ADD [ESP].RegA,EBX
ADD EAX,EBX
MOV [ESP].RegE,EAX
// W[12]:= (((W[10] shr 17) or (W[10] shl 15)) xor
// ((W[10] shr 19) or (W[10] shl 13)) xor (W[10] shr 10)) + W[5] +
// (((W[13] shr 7) or (W[13] shl 25)) xor
// ((W[13] shr 18) or (W[13] shl 14)) xor (W[13] shr 3)) + W[12];
MOV ESI,[EDI].W10
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W13
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W5
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W12
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W12,ESI
// t1:= d + (((a shr 6) or (a shl 26)) xor ((a shr 11) or (a shl 21)) xor
// ((a shr 25) or (a shl 7))) + ((a and b) xor (not a and c)) + $d192e819 + W[12];
MOV EAX,[ESP].RegA
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegB
NOT EAX
AND EAX,[ESP].RegC
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$d192e819
ADD EBX,[ESP].RegD
// t2:= (((e shr 2) or (e shl 30)) xor ((e shr 13) or (e shl 19)) xor
// ((e shr 22) xor (e shl 10))) + ((e and f) xor (e and g) xor (f and g));
MOV EAX,[ESP].RegE
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegF
MOV EBP,[ESP].RegG
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// d:= t1 + t2;
// h:= h + t1;
ADD [ESP].RegH,EBX
ADD EAX,EBX
MOV [ESP].RegD,EAX
// W[13]:= (((W[11] shr 17) or (W[11] shl 15)) xor
// ((W[11] shr 19) or (W[11] shl 13)) xor (W[11] shr 10)) + W[6] +
// (((W[14] shr 7) or (W[14] shl 25)) xor
// ((W[14] shr 18) or (W[14] shl 14)) xor (W[14] shr 3)) + W[13];
MOV ESI,[EDI].W11
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W14
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W6
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W13
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W13,ESI
// t1:= c + (((h shr 6) or (h shl 26)) xor ((h shr 11) or (h shl 21)) xor
// ((h shr 25) or (h shl 7))) + ((h and a) xor (not h and b)) + $d6990624 + W[13];
MOV EAX,[ESP].RegH
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegA
NOT EAX
AND EAX,[ESP].RegB
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$d6990624
ADD EBX,[ESP].RegC
// t2:= (((d shr 2) or (d shl 30)) xor ((d shr 13) or (d shl 19)) xor
// ((d shr 22) xor (d shl 10))) + ((d and e) xor (d and f) xor (e and f));
MOV EAX,[ESP].RegD
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegE
MOV EBP,[ESP].RegF
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// c:= t1 + t2;
// g:= g + t1;
ADD [ESP].RegG,EBX
ADD EAX,EBX
MOV [ESP].RegC,EAX
// W[14]:= (((W[12] shr 17) or (W[12] shl 15)) xor
// ((W[12] shr 19) or (W[12] shl 13)) xor (W[12] shr 10)) + W[7] +
// (((W[15] shr 7) or (W[15] shl 25)) xor
// ((W[15] shr 18) or (W[15] shl 14)) xor (W[15] shr 3)) + W[14];
MOV ESI,[EDI].W12
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W15
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W7
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W14
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W14,ESI
// t1:= b + (((g shr 6) or (g shl 26)) xor ((g shr 11) or (g shl 21)) xor
// ((g shr 25) or (g shl 7))) + ((g and h) xor (not g and a)) + $f40e3585 + W[14];
MOV EAX,[ESP].RegG
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegH
NOT EAX
AND EAX,[ESP].RegA
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$f40e3585
ADD EBX,[ESP].RegB
// t2:= (((c shr 2) or (c shl 30)) xor ((c shr 13) or (c shl 19)) xor
// ((c shr 22) xor (c shl 10))) + ((c and d) xor (c and e) xor (d and e));
MOV EAX,[ESP].RegC
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegD
MOV EBP,[ESP].RegE
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// b:= t1 + t2;
// f:= f + t1;
ADD [ESP].RegF,EBX
ADD EAX,EBX
MOV [ESP].RegB,EAX
// W[15]:= (((W[13] shr 17) or (W[13] shl 15)) xor
// ((W[13] shr 19) or (W[13] shl 13)) xor (W[13] shr 10)) + W[8] +
// (((W[0] shr 7) or (W[0] shl 25)) xor
// ((W[0] shr 18) or (W[0] shl 14)) xor (W[0] shr 3)) + W[15];
MOV ESI,[EDI].W13
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W0
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W8
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W15
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W15,ESI
// t1:= a + (((f shr 6) or (f shl 26)) xor ((f shr 11) or (f shl 21)) xor
// ((f shr 25) or (f shl 7))) + ((f and g) xor (not f and h)) + $106aa070 + W[15];
MOV EAX,[ESP].RegF
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegG
NOT EAX
AND EAX,[ESP].RegH
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$106aa070
ADD EBX,[ESP].RegA
// t2:= (((b shr 2) or (b shl 30)) xor ((b shr 13) or (b shl 19)) xor
// ((b shr 22) xor (b shl 10))) + ((b and c) xor (b and d) xor (c and d));
MOV EAX,[ESP].RegB
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegC
MOV EBP,[ESP].RegD
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// a:= t1 + t2;
// e:= e + t1;
ADD [ESP].RegE,EBX
ADD EAX,EBX
MOV [ESP].RegA,EAX
// W[0]:= (((W[14] shr 17) or (W[14] shl 15)) xor
// ((W[14] shr 19) or (W[14] shl 13)) xor (W[14] shr 10)) + W[9] +
// (((W[1] shr 7) or (W[1] shl 25)) xor
// ((W[1] shr 18) or (W[1] shl 14)) xor (W[1] shr 3)) + W[0];
MOV ESI,[EDI].W14
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W1
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W9
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W0
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W0,ESI
// t1:= h + (((e shr 6) or (e shl 26)) xor ((e shr 11) or (e shl 21)) xor
// ((e shr 25) or (e shl 7))) + ((e and f) xor (not e and g)) + $19a4c116 + W[0];
MOV EAX,[ESP].RegE
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegF
NOT EAX
AND EAX,[ESP].RegG
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$19a4c116
ADD EBX,[ESP].RegH
// t2:= (((a shr 2) or (a shl 30)) xor ((a shr 13) or (a shl 19)) xor
// ((a shr 22) xor (a shl 10))) + ((a and b) xor (a and c) xor (b and c));
MOV EAX,[ESP].RegA
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegB
MOV EBP,[ESP].RegC
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// h:= t1 + t2;
// d:= d + t1;
ADD [ESP].RegD,EBX
ADD EAX,EBX
MOV [ESP].RegH,EAX
// W[1]:= (((W[15] shr 17) or (W[15] shl 15)) xor
// ((W[15] shr 19) or (W[15] shl 13)) xor (W[15] shr 10)) + W[10] +
// (((W[2] shr 7) or (W[2] shl 25)) xor
// ((W[2] shr 18) or (W[2] shl 14)) xor (W[2] shr 3)) + W[1];
MOV ESI,[EDI].W15
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W2
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W10
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W1
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W1,ESI
// t1:= g + (((d shr 6) or (d shl 26)) xor ((d shr 11) or (d shl 21)) xor
// ((d shr 25) or (d shl 7))) + ((d and e) xor (not d and f)) + $1e376c08 + W[1];
MOV EAX,[ESP].RegD
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegE
NOT EAX
AND EAX,[ESP].RegF
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$1e376c08
ADD EBX,[ESP].RegG
// t2:= (((h shr 2) or (h shl 30)) xor ((h shr 13) or (h shl 19)) xor
// ((h shr 22) xor (h shl 10))) + ((h and a) xor (h and b) xor (a and b));
MOV EAX,[ESP].RegH
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegA
MOV EBP,[ESP].RegB
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// g:= t1 + t2;
// c:= c + t1;
ADD [ESP].RegC,EBX
ADD EAX,EBX
MOV [ESP].RegG,EAX
// W[2]:= (((W[0] shr 17) or (W[0] shl 15)) xor
// ((W[0] shr 19) or (W[0] shl 13)) xor (W[0] shr 10)) + W[11] +
// (((W[3] shr 7) or (W[3] shl 25)) xor
// ((W[3] shr 18) or (W[3] shl 14)) xor (W[3] shr 3)) + W[2];
MOV ESI,[EDI].W0
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W3
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W11
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W2
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W2,ESI
// t1:= f + (((c shr 6) or (c shl 26)) xor ((c shr 11) or (c shl 21)) xor
// ((c shr 25) or (c shl 7))) + ((c and d) xor (not c and e)) + $2748774c + W[2];
MOV EAX,[ESP].RegC
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegD
NOT EAX
AND EAX,[ESP].RegE
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$2748774c
ADD EBX,[ESP].RegF
// t2:= (((g shr 2) or (g shl 30)) xor ((g shr 13) or (g shl 19)) xor
// ((g shr 22) xor (g shl 10))) + ((g and h) xor (g and a) xor (h and a));
MOV EAX,[ESP].RegG
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegH
MOV EBP,[ESP].RegA
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// f:= t1 + t2;
// b:= b + t1;
ADD [ESP].RegB,EBX
ADD EAX,EBX
MOV [ESP].RegF,EAX
// W[3]:= (((W[1] shr 17) or (W[1] shl 15)) xor
// ((W[1] shr 19) or (W[1] shl 13)) xor (W[1] shr 10)) + W[12] +
// (((W[4] shr 7) or (W[4] shl 25)) xor
// ((W[4] shr 18) or (W[4] shl 14)) xor (W[4] shr 3)) + W[3];
MOV ESI,[EDI].W1
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W4
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W12
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W3
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W3,ESI
// t1:= e + (((b shr 6) or (b shl 26)) xor ((b shr 11) or (b shl 21)) xor
// ((b shr 25) or (b shl 7))) + ((b and c) xor (not b and d)) + $34b0bcb5 + W[3];
MOV EAX,[ESP].RegB
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegC
NOT EAX
AND EAX,[ESP].RegD
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$34b0bcb5
ADD EBX,[ESP].RegE
// t2:= (((f shr 2) or (f shl 30)) xor ((f shr 13) or (f shl 19)) xor
// ((f shr 22) xor (f shl 10))) + ((f and g) xor (f and h) xor (g and h));
MOV EAX,[ESP].RegF
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegG
MOV EBP,[ESP].RegH
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// e:= t1 + t2;
// a:= a + t1;
ADD [ESP].RegA,EBX
ADD EAX,EBX
MOV [ESP].RegE,EAX
// W[4]:= (((W[2] shr 17) or (W[2] shl 15)) xor
// ((W[2] shr 19) or (W[2] shl 13)) xor (W[2] shr 10)) + W[13] +
// (((W[5] shr 7) or (W[5] shl 25)) xor
// ((W[5] shr 18) or (W[5] shl 14)) xor (W[5] shr 3)) + W[4];
MOV ESI,[EDI].W2
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W5
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W13
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W4
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W4,ESI
// t1:= d + (((a shr 6) or (a shl 26)) xor ((a shr 11) or (a shl 21)) xor
// ((a shr 25) or (a shl 7))) + ((a and b) xor (not a and c)) + $391c0cb3 + W[4];
MOV EAX,[ESP].RegA
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegB
NOT EAX
AND EAX,[ESP].RegC
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$391c0cb3
ADD EBX,[ESP].RegD
// t2:= (((e shr 2) or (e shl 30)) xor ((e shr 13) or (e shl 19)) xor
// ((e shr 22) xor (e shl 10))) + ((e and f) xor (e and g) xor (f and g));
MOV EAX,[ESP].RegE
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegF
MOV EBP,[ESP].RegG
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// d:= t1 + t2;
// h:= h + t1;
ADD [ESP].RegH,EBX
ADD EAX,EBX
MOV [ESP].RegD,EAX
// W[5]:= (((W[3] shr 17) or (W[3] shl 15)) xor
// ((W[3] shr 19) or (W[3] shl 13)) xor (W[3] shr 10)) + W[14] +
// (((W[6] shr 7) or (W[6] shl 25)) xor
// ((W[6] shr 18) or (W[6] shl 14)) xor (W[6] shr 3)) + W[5];
MOV ESI,[EDI].W3
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W6
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W14
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W5
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W5,ESI
// t1:= c + (((h shr 6) or (h shl 26)) xor ((h shr 11) or (h shl 21)) xor
// ((h shr 25) or (h shl 7))) + ((h and a) xor (not h and b)) + $4ed8aa4a + W[5];
MOV EAX,[ESP].RegH
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegA
NOT EAX
AND EAX,[ESP].RegB
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$4ed8aa4a
ADD EBX,[ESP].RegC
// t2:= (((d shr 2) or (d shl 30)) xor ((d shr 13) or (d shl 19)) xor
// ((d shr 22) xor (d shl 10))) + ((d and e) xor (d and f) xor (e and f));
MOV EAX,[ESP].RegD
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegE
MOV EBP,[ESP].RegF
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// c:= t1 + t2;
// g:= g + t1;
ADD [ESP].RegG,EBX
ADD EAX,EBX
MOV [ESP].RegC,EAX
// W[6]:= (((W[4] shr 17) or (W[4] shl 15)) xor
// ((W[4] shr 19) or (W[4] shl 13)) xor (W[4] shr 10)) + W[15] +
// (((W[7] shr 7) or (W[7] shl 25)) xor
// ((W[7] shr 18) or (W[7] shl 14)) xor (W[7] shr 3)) + W[6];
MOV ESI,[EDI].W4
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W7
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W15
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W6
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W6,ESI
// t1:= b + (((g shr 6) or (g shl 26)) xor ((g shr 11) or (g shl 21)) xor
// ((g shr 25) or (g shl 7))) + ((g and h) xor (not g and a)) + $5b9cca4f + W[6];
MOV EAX,[ESP].RegG
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegH
NOT EAX
AND EAX,[ESP].RegA
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$5b9cca4f
ADD EBX,[ESP].RegB
// t2:= (((c shr 2) or (c shl 30)) xor ((c shr 13) or (c shl 19)) xor
// ((c shr 22) xor (c shl 10))) + ((c and d) xor (c and e) xor (d and e));
MOV EAX,[ESP].RegC
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegD
MOV EBP,[ESP].RegE
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// b:= t1 + t2;
// f:= f + t1;
ADD [ESP].RegF,EBX
ADD EAX,EBX
MOV [ESP].RegB,EAX
// W[7]:= (((W[5] shr 17) or (W[5] shl 15)) xor
// ((W[5] shr 19) or (W[5] shl 13)) xor (W[5] shr 10)) + W[0] +
// (((W[8] shr 7) or (W[8] shl 25)) xor
// ((W[8] shr 18) or (W[8] shl 14)) xor (W[8] shr 3)) + W[7];
MOV ESI,[EDI].W5
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W8
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W0
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W7
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W7,ESI
// t1:= a + (((f shr 6) or (f shl 26)) xor ((f shr 11) or (f shl 21)) xor
// ((f shr 25) or (f shl 7))) + ((f and g) xor (not f and h)) + $682e6ff3 + W[7];
MOV EAX,[ESP].RegF
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegG
NOT EAX
AND EAX,[ESP].RegH
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$682e6ff3
ADD EBX,[ESP].RegA
// t2:= (((b shr 2) or (b shl 30)) xor ((b shr 13) or (b shl 19)) xor
// ((b shr 22) xor (b shl 10))) + ((b and c) xor (b and d) xor (c and d));
MOV EAX,[ESP].RegB
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegC
MOV EBP,[ESP].RegD
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// a:= t1 + t2;
// e:= e + t1;
ADD [ESP].RegE,EBX
ADD EAX,EBX
MOV [ESP].RegA,EAX
// W[8]:= (((W[6] shr 17) or (W[6] shl 15)) xor
// ((W[6] shr 19) or (W[6] shl 13)) xor (W[6] shr 10)) + W[1] +
// (((W[9] shr 7) or (W[9] shl 25)) xor
// ((W[9] shr 18) or (W[9] shl 14)) xor (W[9] shr 3)) + W[8];
MOV ESI,[EDI].W6
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W9
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W1
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W8
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W8,ESI
// t1:= h + (((e shr 6) or (e shl 26)) xor ((e shr 11) or (e shl 21)) xor
// ((e shr 25) or (e shl 7))) + ((e and f) xor (not e and g)) + $748f82ee + W[8];
MOV EAX,[ESP].RegE
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegF
NOT EAX
AND EAX,[ESP].RegG
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$748f82ee
ADD EBX,[ESP].RegH
// t2:= (((a shr 2) or (a shl 30)) xor ((a shr 13) or (a shl 19)) xor
// ((a shr 22) xor (a shl 10))) + ((a and b) xor (a and c) xor (b and c));
MOV EAX,[ESP].RegA
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegB
MOV EBP,[ESP].RegC
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// h:= t1 + t2;
// d:= d + t1;
ADD [ESP].RegD,EBX
ADD EAX,EBX
MOV [ESP].RegH,EAX
// W[9]:= (((W[7] shr 17) or (W[7] shl 15)) xor
// ((W[7] shr 19) or (W[7] shl 13)) xor (W[7] shr 10)) + W[2] +
// (((W[10] shr 7) or (W[10] shl 25)) xor
// ((W[10] shr 18) or (W[10] shl 14)) xor (W[10] shr 3)) + W[9];
MOV ESI,[EDI].W7
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W10
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W2
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W9
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W9,ESI
// t1:= g + (((d shr 6) or (d shl 26)) xor ((d shr 11) or (d shl 21)) xor
// ((d shr 25) or (d shl 7))) + ((d and e) xor (not d and f)) + $78a5636f + W[9];
MOV EAX,[ESP].RegD
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegE
NOT EAX
AND EAX,[ESP].RegF
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$78a5636f
ADD EBX,[ESP].RegG
// t2:= (((h shr 2) or (h shl 30)) xor ((h shr 13) or (h shl 19)) xor
// ((h shr 22) xor (h shl 10))) + ((h and a) xor (h and b) xor (a and b));
MOV EAX,[ESP].RegH
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegA
MOV EBP,[ESP].RegB
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// g:= t1 + t2;
// c:= c + t1;
ADD [ESP].RegC,EBX
ADD EAX,EBX
MOV [ESP].RegG,EAX
// W[10]:= (((W[8] shr 17) or (W[8] shl 15)) xor
// ((W[8] shr 19) or (W[8] shl 13)) xor (W[8] shr 10)) + W[3] +
// (((W[11] shr 7) or (W[11] shl 25)) xor
// ((W[11] shr 18) or (W[11] shl 14)) xor (W[11] shr 3)) + W[10];
MOV ESI,[EDI].W8
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W11
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W3
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W10
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W10,ESI
// t1:= f + (((c shr 6) or (c shl 26)) xor ((c shr 11) or (c shl 21)) xor
// ((c shr 25) or (c shl 7))) + ((c and d) xor (not c and e)) + $84c87814 + W[10];
MOV EAX,[ESP].RegC
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegD
NOT EAX
AND EAX,[ESP].RegE
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$84c87814
ADD EBX,[ESP].RegF
// t2:= (((g shr 2) or (g shl 30)) xor ((g shr 13) or (g shl 19)) xor
// ((g shr 22) xor (g shl 10))) + ((g and h) xor (g and a) xor (h and a));
MOV EAX,[ESP].RegG
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegH
MOV EBP,[ESP].RegA
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// f:= t1 + t2;
// b:= b + t1;
ADD [ESP].RegB,EBX
ADD EAX,EBX
MOV [ESP].RegF,EAX
// W[11]:= (((W[9] shr 17) or (W[9] shl 15)) xor
// ((W[9] shr 19) or (W[9] shl 13)) xor (W[9] shr 10)) + W[4] +
// (((W[12] shr 7) or (W[12] shl 25)) xor
// ((W[12] shr 18) or (W[12] shl 14)) xor (W[12] shr 3)) + W[11];
MOV ESI,[EDI].W9
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W12
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W4
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W11
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W11,ESI
// t1:= e + (((b shr 6) or (b shl 26)) xor ((b shr 11) or (b shl 21)) xor
// ((b shr 25) or (b shl 7))) + ((b and c) xor (not b and d)) + $8cc70208 + W[11];
MOV EAX,[ESP].RegB
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegC
NOT EAX
AND EAX,[ESP].RegD
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$8cc70208
ADD EBX,[ESP].RegE
// t2:= (((f shr 2) or (f shl 30)) xor ((f shr 13) or (f shl 19)) xor
// ((f shr 22) xor (f shl 10))) + ((f and g) xor (f and h) xor (g and h));
MOV EAX,[ESP].RegF
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegG
MOV EBP,[ESP].RegH
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// e:= t1 + t2;
// a:= a + t1;
ADD [ESP].RegA,EBX
ADD EAX,EBX
MOV [ESP].RegE,EAX
// W[12]:= (((W[10] shr 17) or (W[10] shl 15)) xor
// ((W[10] shr 19) or (W[10] shl 13)) xor (W[10] shr 10)) + W[5] +
// (((W[13] shr 7) or (W[13] shl 25)) xor
// ((W[13] shr 18) or (W[13] shl 14)) xor (W[13] shr 3)) + W[12];
MOV ESI,[EDI].W10
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W13
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W5
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W12
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W12,ESI
// t1:= d + (((a shr 6) or (a shl 26)) xor ((a shr 11) or (a shl 21)) xor
// ((a shr 25) or (a shl 7))) + ((a and b) xor (not a and c)) + $90befffa + W[12];
MOV EAX,[ESP].RegA
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegB
NOT EAX
AND EAX,[ESP].RegC
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$90befffa
ADD EBX,[ESP].RegD
// t2:= (((e shr 2) or (e shl 30)) xor ((e shr 13) or (e shl 19)) xor
// ((e shr 22) xor (e shl 10))) + ((e and f) xor (e and g) xor (f and g));
MOV EAX,[ESP].RegE
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegF
MOV EBP,[ESP].RegG
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// d:= t1 + t2;
// h:= h + t1;
ADD [ESP].RegH,EBX
ADD EAX,EBX
MOV [ESP].RegD,EAX
// W[13]:= (((W[11] shr 17) or (W[11] shl 15)) xor
// ((W[11] shr 19) or (W[11] shl 13)) xor (W[11] shr 10)) + W[6] +
// (((W[14] shr 7) or (W[14] shl 25)) xor
// ((W[14] shr 18) or (W[14] shl 14)) xor (W[14] shr 3)) + W[13];
MOV ESI,[EDI].W11
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W14
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W6
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W13
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W13,ESI
// t1:= c + (((h shr 6) or (h shl 26)) xor ((h shr 11) or (h shl 21)) xor
// ((h shr 25) or (h shl 7))) + ((h and a) xor (not h and b)) + $a4506ceb + W[13];
MOV EAX,[ESP].RegH
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegA
NOT EAX
AND EAX,[ESP].RegB
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$a4506ceb
ADD EBX,[ESP].RegC
// t2:= (((d shr 2) or (d shl 30)) xor ((d shr 13) or (d shl 19)) xor
// ((d shr 22) xor (d shl 10))) + ((d and e) xor (d and f) xor (e and f));
MOV EAX,[ESP].RegD
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegE
MOV EBP,[ESP].RegF
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// c:= t1 + t2;
// g:= g + t1;
ADD [ESP].RegG,EBX
ADD EAX,EBX
MOV [ESP].RegC,EAX
// W[14]:= (((W[12] shr 17) or (W[12] shl 15)) xor
// ((W[12] shr 19) or (W[12] shl 13)) xor (W[12] shr 10)) + W[7] +
// (((W[15] shr 7) or (W[15] shl 25)) xor
// ((W[15] shr 18) or (W[15] shl 14)) xor (W[15] shr 3)) + W[14];
MOV ESI,[EDI].W12
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W15
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W7
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W14
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W14,ESI
// t1:= b + (((g shr 6) or (g shl 26)) xor ((g shr 11) or (g shl 21)) xor
// ((g shr 25) or (g shl 7))) + ((g and h) xor (not g and a)) + $bef9a3f7 + W[14];
MOV EAX,[ESP].RegG
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegH
NOT EAX
AND EAX,[ESP].RegA
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$bef9a3f7
ADD EBX,[ESP].RegB
// t2:= (((c shr 2) or (c shl 30)) xor ((c shr 13) or (c shl 19)) xor
// ((c shr 22) xor (c shl 10))) + ((c and d) xor (c and e) xor (d and e));
MOV EAX,[ESP].RegC
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegD
MOV EBP,[ESP].RegE
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// b:= t1 + t2;
// f:= f + t1;
ADD [ESP].RegF,EBX
ADD EAX,EBX
MOV [ESP].RegB,EAX
// W[15]:= (((W[13] shr 17) or (W[13] shl 15)) xor
// ((W[13] shr 19) or (W[13] shl 13)) xor (W[13] shr 10)) + W[8] +
// (((W[0] shr 7) or (W[0] shl 25)) xor
// ((W[0] shr 18) or (W[0] shl 14)) xor (W[0] shr 3)) + W[15];
MOV ESI,[EDI].W13
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[EDI].W0
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[EDI].W8
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[EDI].W15
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [EDI].W15,ESI
// t1:= a + (((f shr 6) or (f shl 26)) xor ((f shr 11) or (f shl 21)) xor
// ((f shr 25) or (f shl 7))) + ((f and g) xor (not f and h)) + $c67178f2 + W[15];
MOV EAX,[ESP].RegF
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,[ESP].RegG
NOT EAX
AND EAX,[ESP].RegH
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$c67178f2
ADD EBX,[ESP].RegA
// t2:= (((b shr 2) or (b shl 30)) xor ((b shr 13) or (b shl 19)) xor
// ((b shr 22) xor (b shl 10))) + ((b and c) xor (b and d) xor (c and d));
MOV EAX,[ESP].RegB
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,[ESP].RegC
MOV EBP,[ESP].RegD
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// a:= t1 + t2;
// e:= e + t1;
ADD [ESP].RegE,EBX
ADD EAX,EBX
MOV [ESP].RegA,EAX
POP EAX
ADD [EDI].DigestH,EAX
POP EAX
ADD [EDI].DigestG,EAX
POP EAX
ADD [EDI].DigestF,EAX
POP EAX
ADD [EDI].DigestE,EAX
POP EAX
ADD [EDI].DigestD,EAX
POP EAX
ADD [EDI].DigestC,EAX
POP EAX
ADD [EDI].DigestB,EAX
POP EAX
ADD [EDI].DigestA,EAX
{
MOV EAX,[ESP].RegA
MOV [EDI].DigestA,EAX
MOV EAX,[ESP].RegB
MOV [EDI].DigestB,EAX
MOV EAX,[ESP].RegC
MOV [EDI].DigestC,EAX
MOV EAX,[ESP].RegD
MOV [EDI].DigestD,EAX
MOV EAX,[ESP].RegE
MOV [EDI].DigestE,EAX
MOV EAX,[ESP].RegF
MOV [EDI].DigestF,EAX
MOV EAX,[ESP].RegG
MOV [EDI].DigestG,EAX
MOV EAX,[ESP].RegH
MOV [EDI].DigestH,EAX
XOR EAX,EAX
MOV [ESP].RegA,EAX
MOV [ESP].RegB,EAX
MOV [ESP].RegC,EAX
MOV [ESP].RegD,EAX
MOV [ESP].RegE,EAX
MOV [ESP].RegF,EAX
MOV [ESP].RegG,EAX
MOV [ESP].RegH,EAX
ADD ESP,32
}
XOR EAX,EAX
MOV [EDI].W0,EAX
MOV [EDI].W1,EAX
MOV [EDI].W2,EAX
MOV [EDI].W3,EAX
MOV [EDI].W4,EAX
MOV [EDI].W5,EAX
MOV [EDI].W6,EAX
MOV [EDI].W7,EAX
MOV [EDI].W8,EAX
MOV [EDI].W9,EAX
MOV [EDI].W10,EAX
MOV [EDI].W11,EAX
MOV [EDI].W12,EAX
MOV [EDI].W13,EAX
MOV [EDI].W14,EAX
MOV [EDI].W15,EAX
POP EBP
POP EBX
POP EDI
POP ESI
end;
{$ENDIF}
{$IFDEF CPUX64_WIN64}
{------------
RegA = R8D
RegB = R9D
RegC = R10D
RegD = R11D
RegE = R12D
RegF = R13D
RegG = R14D
RegH = R15D
-------------}
procedure TSHA256Alg.Compress;{$IFDEF FPC}assembler; nostackframe;{$ENDIF}
const
// SHA256 registers:
DigestA = -32; // [RDI - 32]
DigestB = -28; // [RDI - 28]
DigestC = -24; // [RDI - 24]
DigestD = -20; // [RDI - 20]
DigestE = -16; // [RDI - 16]
DigestF = -12; // [RDI - 12]
DigestG = -8; // [RDI - 8]
DigestH = -4; // [RDI - 4]
W0 = 0; W1 = 4; W2 = 8; W3 = 12;
W4 = 16; W5 = 20; W6 = 24; W7 = 28;
W8 = 32; W9 = 36; W10 = 40; W11 = 44;
W12 = 48; W13 = 52; W14 = 56; W15 = 60;
asm
{$IFNDEF FPC}
.NOFRAME
{$ENDIF}
PUSH RSI
PUSH RDI
PUSH RBX
PUSH RBP
PUSH R12
PUSH R13
PUSH R14
PUSH R15
SUB RSP,8
LEA RDI,[RCX].TSHA256Alg.FData.Block // W:= @FData.Block;
MOV R8D,[RDI].DigestA
MOV R9D,[RDI].DigestB
MOV R10D,[RDI].DigestC
MOV R11D,[RDI].DigestD
MOV R12D,[RDI].DigestE
MOV R13D,[RDI].DigestF
MOV R14D,[RDI].DigestG
MOV R15D,[RDI].DigestH
// W[0]:= Swap32(W[0]);
MOV ESI,[RDI].W0
BSWAP ESI
MOV [RDI].W0,ESI
// t1:= h + (((e shr 6) or (e shl 26)) xor ((e shr 11) or (e shl 21)) xor
// ((e shr 25) or (e shl 7))) + ((e and f) xor (not e and g)) + $428a2f98 + W[0];
MOV EAX,R12D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R13D
NOT EAX
AND EAX,R14D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$428a2f98
ADD EBX,R15D
// t2:= (((a shr 2) or (a shl 30)) xor ((a shr 13) or (a shl 19)) xor
// ((a shr 22) xor (a shl 10))) + ((a and b) xor (a and c) xor (b and c));
MOV EAX,R8D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R9D
MOV EBP,R10D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// h:= t1 + t2;
// d:= d + t1;
ADD R11D,EBX
ADD EAX,EBX
MOV R15D,EAX
// W[1]:= Swap32(W[1]);
MOV ESI,[RDI].W1
BSWAP ESI
MOV [RDI].W1,ESI
// t1:= g + (((d shr 6) or (d shl 26)) xor ((d shr 11) or (d shl 21)) xor
// ((d shr 25) or (d shl 7))) + ((d and e) xor (not d and f)) + $71374491 + W[1];
MOV EAX,R11D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R12D
NOT EAX
AND EAX,R13D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$71374491
ADD EBX,R14D
// t2:= (((h shr 2) or (h shl 30)) xor ((h shr 13) or (h shl 19)) xor
// ((h shr 22) xor (h shl 10))) + ((h and a) xor (h and b) xor (a and b));
MOV EAX,R15D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R8D
MOV EBP,R9D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// g:= t1 + t2;
// c:= c + t1;
ADD R10D,EBX
ADD EAX,EBX
MOV R14D,EAX
// W[2]:= Swap32(W[2]);
MOV ESI,[RDI].W2
BSWAP ESI
MOV [RDI].W2,ESI
// t1:= f + (((c shr 6) or (c shl 26)) xor ((c shr 11) or (c shl 21)) xor
// ((c shr 25) or (c shl 7))) + ((c and d) xor (not c and e)) + $b5c0fbcf + W[2];
MOV EAX,R10D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R11D
NOT EAX
AND EAX,R12D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$b5c0fbcf
ADD EBX,R13D
// t2:= (((g shr 2) or (g shl 30)) xor ((g shr 13) or (g shl 19)) xor
// ((g shr 22) xor (g shl 10))) + ((g and h) xor (g and a) xor (h and a));
MOV EAX,R14D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R15D
MOV EBP,R8D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// f:= t1 + t2;
// b:= b + t1;
ADD R9D,EBX
ADD EAX,EBX
MOV R13D,EAX
// W[3]:= Swap32(W[3]);
MOV ESI,[RDI].W3
BSWAP ESI
MOV [RDI].W3,ESI
// t1:= e + (((b shr 6) or (b shl 26)) xor ((b shr 11) or (b shl 21)) xor
// ((b shr 25) or (b shl 7))) + ((b and c) xor (not b and d)) + $e9b5dba5 + W[3];
MOV EAX,R9D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R10D
NOT EAX
AND EAX,R11D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$e9b5dba5
ADD EBX,R12D
// t2:= (((f shr 2) or (f shl 30)) xor ((f shr 13) or (f shl 19)) xor
// ((f shr 22) xor (f shl 10))) + ((f and g) xor (f and h) xor (g and h));
MOV EAX,R13D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R14D
MOV EBP,R15D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// e:= t1 + t2;
// a:= a + t1;
ADD R8D,EBX
ADD EAX,EBX
MOV R12D,EAX
// W[4]:= Swap32(W[4]);
MOV ESI,[RDI].W4
BSWAP ESI
MOV [RDI].W4,ESI
// t1:= d + (((a shr 6) or (a shl 26)) xor ((a shr 11) or (a shl 21)) xor
// ((a shr 25) or (a shl 7))) + ((a and b) xor (not a and c)) + $3956c25b + W[4];
MOV EAX,R8D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R9D
NOT EAX
AND EAX,R10D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$3956c25b
ADD EBX,R11D
// t2:= (((e shr 2) or (e shl 30)) xor ((e shr 13) or (e shl 19)) xor
// ((e shr 22) xor (e shl 10))) + ((e and f) xor (e and g) xor (f and g));
MOV EAX,R12D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R13D
MOV EBP,R14D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// d:= t1 + t2;
// h:= h + t1;
ADD R15D,EBX
ADD EAX,EBX
MOV R11D,EAX
// W[5]:= Swap32(W[5]);
MOV ESI,[RDI].W5
BSWAP ESI
MOV [RDI].W5,ESI
// t1:= c + (((h shr 6) or (h shl 26)) xor ((h shr 11) or (h shl 21)) xor
// ((h shr 25) or (h shl 7))) + ((h and a) xor (not h and b)) + $59f111f1 + W[5];
MOV EAX,R15D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R8D
NOT EAX
AND EAX,R9D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$59f111f1
ADD EBX,R10D
// t2:= (((d shr 2) or (d shl 30)) xor ((d shr 13) or (d shl 19)) xor
// ((d shr 22) xor (d shl 10))) + ((d and e) xor (d and f) xor (e and f));
MOV EAX,R11D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R12D
MOV EBP,R13D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// c:= t1 + t2;
// g:= g + t1;
ADD R14D,EBX
ADD EAX,EBX
MOV R10D,EAX
// W[6]:= Swap32(W[6]);
MOV ESI,[RDI].W6
BSWAP ESI
MOV [RDI].W6,ESI
// t1:= b + (((g shr 6) or (g shl 26)) xor ((g shr 11) or (g shl 21)) xor
// ((g shr 25) or (g shl 7))) + ((g and h) xor (not g and a)) + $923f82a4 + W[6];
MOV EAX,R14D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R15D
NOT EAX
AND EAX,R8D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$923f82a4
ADD EBX,R9D
// t2:= (((c shr 2) or (c shl 30)) xor ((c shr 13) or (c shl 19)) xor
// ((c shr 22) xor (c shl 10))) + ((c and d) xor (c and e) xor (d and e));
MOV EAX,R10D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R11D
MOV EBP,R12D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// b:= t1 + t2;
// f:= f + t1;
ADD R13D,EBX
ADD EAX,EBX
MOV R9D,EAX
// W[7]:= Swap32(W[7]);
MOV ESI,[RDI].W7
BSWAP ESI
MOV [RDI].W7,ESI
// t1:= a + (((f shr 6) or (f shl 26)) xor ((f shr 11) or (f shl 21)) xor
// ((f shr 25) or (f shl 7))) + ((f and g) xor (not f and h)) + $ab1c5ed5 + W[7];
MOV EAX,R13D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R14D
NOT EAX
AND EAX,R15D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$ab1c5ed5
ADD EBX,R8D
// t2:= (((b shr 2) or (b shl 30)) xor ((b shr 13) or (b shl 19)) xor
// ((b shr 22) xor (b shl 10))) + ((b and c) xor (b and d) xor (c and d));
MOV EAX,R9D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R10D
MOV EBP,R11D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// a:= t1 + t2;
// e:= e + t1;
ADD R12D,EBX
ADD EAX,EBX
MOV R8D,EAX
// W[8]:= Swap32(W[8]);
MOV ESI,[RDI].W8
BSWAP ESI
MOV [RDI].W8,ESI
// t1:= h + (((e shr 6) or (e shl 26)) xor ((e shr 11) or (e shl 21)) xor
// ((e shr 25) or (e shl 7))) + ((e and f) xor (not e and g)) + $d807aa98 + W[8];
MOV EAX,R12D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R13D
NOT EAX
AND EAX,R14D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$d807aa98
ADD EBX,R15D
// t2:= (((a shr 2) or (a shl 30)) xor ((a shr 13) or (a shl 19)) xor
// ((a shr 22) xor (a shl 10))) + ((a and b) xor (a and c) xor (b and c));
MOV EAX,R8D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R9D
MOV EBP,R10D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// h:= t1 + t2;
// d:= d + t1;
ADD R11D,EBX
ADD EAX,EBX
MOV R15D,EAX
// W[9]:= Swap32(W[9]);
MOV ESI,[RDI].W9
BSWAP ESI
MOV [RDI].W9,ESI
// t1:= g + (((d shr 6) or (d shl 26)) xor ((d shr 11) or (d shl 21)) xor
// ((d shr 25) or (d shl 7))) + ((d and e) xor (not d and f)) + $12835b01 + W[9];
MOV EAX,R11D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R12D
NOT EAX
AND EAX,R13D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$12835b01
ADD EBX,R14D
// t2:= (((h shr 2) or (h shl 30)) xor ((h shr 13) or (h shl 19)) xor
// ((h shr 22) xor (h shl 10))) + ((h and a) xor (h and b) xor (a and b));
MOV EAX,R15D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R8D
MOV EBP,R9D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// g:= t1 + t2;
// c:= c + t1;
ADD R10D,EBX
ADD EAX,EBX
MOV R14D,EAX
// W[10]:= Swap32(W[10]);
MOV ESI,[RDI].W10
BSWAP ESI
MOV [RDI].W10,ESI
// t1:= f + (((c shr 6) or (c shl 26)) xor ((c shr 11) or (c shl 21)) xor
// ((c shr 25) or (c shl 7))) + ((c and d) xor (not c and e)) + $243185be + W[10];
MOV EAX,R10D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R11D
NOT EAX
AND EAX,R12D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$243185be
ADD EBX,R13D
// t2:= (((g shr 2) or (g shl 30)) xor ((g shr 13) or (g shl 19)) xor
// ((g shr 22) xor (g shl 10))) + ((g and h) xor (g and a) xor (h and a));
MOV EAX,R14D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R15D
MOV EBP,R8D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// f:= t1 + t2;
// b:= b + t1;
ADD R9D,EBX
ADD EAX,EBX
MOV R13D,EAX
// W[11]:= Swap32(W[11]);
MOV ESI,[RDI].W11
BSWAP ESI
MOV [RDI].W11,ESI
// t1:= e + (((b shr 6) or (b shl 26)) xor ((b shr 11) or (b shl 21)) xor
// ((b shr 25) or (b shl 7))) + ((b and c) xor (not b and d)) + $550c7dc3 + W[11];
MOV EAX,R9D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R10D
NOT EAX
AND EAX,R11D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$550c7dc3
ADD EBX,R12D
// t2:= (((f shr 2) or (f shl 30)) xor ((f shr 13) or (f shl 19)) xor
// ((f shr 22) xor (f shl 10))) + ((f and g) xor (f and h) xor (g and h));
MOV EAX,R13D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R14D
MOV EBP,R15D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// e:= t1 + t2;
// a:= a + t1;
ADD R8D,EBX
ADD EAX,EBX
MOV R12D,EAX
// W[12]:= Swap32(W[12]);
MOV ESI,[RDI].W12
BSWAP ESI
MOV [RDI].W12,ESI
// t1:= d + (((a shr 6) or (a shl 26)) xor ((a shr 11) or (a shl 21)) xor
// ((a shr 25) or (a shl 7))) + ((a and b) xor (not a and c)) + $72be5d74 + W[12];
MOV EAX,R8D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R9D
NOT EAX
AND EAX,R10D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$72be5d74
ADD EBX,R11D
// t2:= (((e shr 2) or (e shl 30)) xor ((e shr 13) or (e shl 19)) xor
// ((e shr 22) xor (e shl 10))) + ((e and f) xor (e and g) xor (f and g));
MOV EAX,R12D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R13D
MOV EBP,R14D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// d:= t1 + t2;
// h:= h + t1;
ADD R15D,EBX
ADD EAX,EBX
MOV R11D,EAX
// W[13]:= Swap32(W[13]);
MOV ESI,[RDI].W13
BSWAP ESI
MOV [RDI].W13,ESI
// t1:= c + (((h shr 6) or (h shl 26)) xor ((h shr 11) or (h shl 21)) xor
// ((h shr 25) or (h shl 7))) + ((h and a) xor (not h and b)) + $80deb1fe + W[13];
MOV EAX,R15D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R8D
NOT EAX
AND EAX,R9D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$80deb1fe
ADD EBX,R10D
// t2:= (((d shr 2) or (d shl 30)) xor ((d shr 13) or (d shl 19)) xor
// ((d shr 22) xor (d shl 10))) + ((d and e) xor (d and f) xor (e and f));
MOV EAX,R11D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R12D
MOV EBP,R13D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// c:= t1 + t2;
// g:= g + t1;
ADD R14D,EBX
ADD EAX,EBX
MOV R10D,EAX
// W[14]:= Swap32(W[14]);
MOV ESI,[RDI].W14
BSWAP ESI
MOV [RDI].W14,ESI
// t1:= b + (((g shr 6) or (g shl 26)) xor ((g shr 11) or (g shl 21)) xor
// ((g shr 25) or (g shl 7))) + ((g and h) xor (not g and a)) + $9bdc06a7 + W[14];
MOV EAX,R14D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R15D
NOT EAX
AND EAX,R8D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$9bdc06a7
ADD EBX,R9D
// t2:= (((c shr 2) or (c shl 30)) xor ((c shr 13) or (c shl 19)) xor
// ((c shr 22) xor (c shl 10))) + ((c and d) xor (c and e) xor (d and e));
MOV EAX,R10D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R11D
MOV EBP,R12D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// b:= t1 + t2;
// f:= f + t1;
ADD R13D,EBX
ADD EAX,EBX
MOV R9D,EAX
// W[15]:= Swap32(W[15]);
MOV ESI,[RDI].W15
BSWAP ESI
MOV [RDI].W15,ESI
// t1:= a + (((f shr 6) or (f shl 26)) xor ((f shr 11) or (f shl 21)) xor
// ((f shr 25) or (f shl 7))) + ((f and g) xor (not f and h)) + $c19bf174 + W[15];
MOV EAX,R13D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R14D
NOT EAX
AND EAX,R15D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$c19bf174
ADD EBX,R8D
// t2:= (((b shr 2) or (b shl 30)) xor ((b shr 13) or (b shl 19)) xor
// ((b shr 22) xor (b shl 10))) + ((b and c) xor (b and d) xor (c and d));
MOV EAX,R9D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R10D
MOV EBP,R11D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// a:= t1 + t2;
// e:= e + t1;
ADD R12D,EBX
ADD EAX,EBX
MOV R8D,EAX
// W[0]:= (((W[14] shr 17) or (W[14] shl 15)) xor
// ((W[14] shr 19) or (W[14] shl 13)) xor (W[14] shr 10)) + W[9] +
// (((W[1] shr 7) or (W[1] shl 25)) xor
// ((W[1] shr 18) or (W[1] shl 14)) xor (W[1] shr 3)) + W[0];
MOV ESI,[RDI].W14
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W1
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W9
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W0
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W0,ESI
// t1:= h + (((e shr 6) or (e shl 26)) xor ((e shr 11) or (e shl 21)) xor
// ((e shr 25) or (e shl 7))) + ((e and f) xor (not e and g)) + $e49b69c1 + W[0];
MOV EAX,R12D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R13D
NOT EAX
AND EAX,R14D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$e49b69c1
ADD EBX,R15D
// t2:= (((a shr 2) or (a shl 30)) xor ((a shr 13) or (a shl 19)) xor
// ((a shr 22) xor (a shl 10))) + ((a and b) xor (a and c) xor (b and c));
MOV EAX,R8D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R9D
MOV EBP,R10D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// h:= t1 + t2;
// d:= d + t1;
ADD R11D,EBX
ADD EAX,EBX
MOV R15D,EAX
// W[1]:= (((W[15] shr 17) or (W[15] shl 15)) xor
// ((W[15] shr 19) or (W[15] shl 13)) xor (W[15] shr 10)) + W[10] +
// (((W[2] shr 7) or (W[2] shl 25)) xor
// ((W[2] shr 18) or (W[2] shl 14)) xor (W[2] shr 3)) + W[1];
MOV ESI,[RDI].W15
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W2
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W10
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W1
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W1,ESI
// t1:= g + (((d shr 6) or (d shl 26)) xor ((d shr 11) or (d shl 21)) xor
// ((d shr 25) or (d shl 7))) + ((d and e) xor (not d and f)) + $efbe4786 + W[1];
MOV EAX,R11D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R12D
NOT EAX
AND EAX,R13D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$efbe4786
ADD EBX,R14D
// t2:= (((h shr 2) or (h shl 30)) xor ((h shr 13) or (h shl 19)) xor
// ((h shr 22) xor (h shl 10))) + ((h and a) xor (h and b) xor (a and b));
MOV EAX,R15D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R8D
MOV EBP,R9D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// g:= t1 + t2;
// c:= c + t1;
ADD R10D,EBX
ADD EAX,EBX
MOV R14D,EAX
// W[2]:= (((W[0] shr 17) or (W[0] shl 15)) xor
// ((W[0] shr 19) or (W[0] shl 13)) xor (W[0] shr 10)) + W[11] +
// (((W[3] shr 7) or (W[3] shl 25)) xor
// ((W[3] shr 18) or (W[3] shl 14)) xor (W[3] shr 3)) + W[2];
MOV ESI,[RDI].W0
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W3
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W11
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W2
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W2,ESI
// t1:= f + (((c shr 6) or (c shl 26)) xor ((c shr 11) or (c shl 21)) xor
// ((c shr 25) or (c shl 7))) + ((c and d) xor (not c and e)) + $0fc19dc6 + W[2];
MOV EAX,R10D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R11D
NOT EAX
AND EAX,R12D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$0fc19dc6
ADD EBX,R13D
// t2:= (((g shr 2) or (g shl 30)) xor ((g shr 13) or (g shl 19)) xor
// ((g shr 22) xor (g shl 10))) + ((g and h) xor (g and a) xor (h and a));
MOV EAX,R14D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R15D
MOV EBP,R8D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// f:= t1 + t2;
// b:= b + t1;
ADD R9D,EBX
ADD EAX,EBX
MOV R13D,EAX
// W[3]:= (((W[1] shr 17) or (W[1] shl 15)) xor
// ((W[1] shr 19) or (W[1] shl 13)) xor (W[1] shr 10)) + W[12] +
// (((W[4] shr 7) or (W[4] shl 25)) xor
// ((W[4] shr 18) or (W[4] shl 14)) xor (W[4] shr 3)) + W[3];
MOV ESI,[RDI].W1
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W4
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W12
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W3
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W3,ESI
// t1:= e + (((b shr 6) or (b shl 26)) xor ((b shr 11) or (b shl 21)) xor
// ((b shr 25) or (b shl 7))) + ((b and c) xor (not b and d)) + $240ca1cc + W[3];
MOV EAX,R9D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R10D
NOT EAX
AND EAX,R11D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$240ca1cc
ADD EBX,R12D
// t2:= (((f shr 2) or (f shl 30)) xor ((f shr 13) or (f shl 19)) xor
// ((f shr 22) xor (f shl 10))) + ((f and g) xor (f and h) xor (g and h));
MOV EAX,R13D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R14D
MOV EBP,R15D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// e:= t1 + t2;
// a:= a + t1;
ADD R8D,EBX
ADD EAX,EBX
MOV R12D,EAX
// W[4]:= (((W[2] shr 17) or (W[2] shl 15)) xor
// ((W[2] shr 19) or (W[2] shl 13)) xor (W[2] shr 10)) + W[13] +
// (((W[5] shr 7) or (W[5] shl 25)) xor
// ((W[5] shr 18) or (W[5] shl 14)) xor (W[5] shr 3)) + W[4];
MOV ESI,[RDI].W2
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W5
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W13
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W4
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W4,ESI
// t1:= d + (((a shr 6) or (a shl 26)) xor ((a shr 11) or (a shl 21)) xor
// ((a shr 25) or (a shl 7))) + ((a and b) xor (not a and c)) + $2de92c6f + W[4];
MOV EAX,R8D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R9D
NOT EAX
AND EAX,R10D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$2de92c6f
ADD EBX,R11D
// t2:= (((e shr 2) or (e shl 30)) xor ((e shr 13) or (e shl 19)) xor
// ((e shr 22) xor (e shl 10))) + ((e and f) xor (e and g) xor (f and g));
MOV EAX,R12D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R13D
MOV EBP,R14D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// d:= t1 + t2;
// h:= h + t1;
ADD R15D,EBX
ADD EAX,EBX
MOV R11D,EAX
// W[5]:= (((W[3] shr 17) or (W[3] shl 15)) xor
// ((W[3] shr 19) or (W[3] shl 13)) xor (W[3] shr 10)) + W[14] +
// (((W[6] shr 7) or (W[6] shl 25)) xor
// ((W[6] shr 18) or (W[6] shl 14)) xor (W[6] shr 3)) + W[5];
MOV ESI,[RDI].W3
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W6
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W14
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W5
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W5,ESI
// t1:= c + (((h shr 6) or (h shl 26)) xor ((h shr 11) or (h shl 21)) xor
// ((h shr 25) or (h shl 7))) + ((h and a) xor (not h and b)) + $4a7484aa + W[5];
MOV EAX,R15D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R8D
NOT EAX
AND EAX,R9D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$4a7484aa
ADD EBX,R10D
// t2:= (((d shr 2) or (d shl 30)) xor ((d shr 13) or (d shl 19)) xor
// ((d shr 22) xor (d shl 10))) + ((d and e) xor (d and f) xor (e and f));
MOV EAX,R11D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R12D
MOV EBP,R13D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// c:= t1 + t2;
// g:= g + t1;
ADD R14D,EBX
ADD EAX,EBX
MOV R10D,EAX
// W[6]:= (((W[4] shr 17) or (W[4] shl 15)) xor
// ((W[4] shr 19) or (W[4] shl 13)) xor (W[4] shr 10)) + W[15] +
// (((W[7] shr 7) or (W[7] shl 25)) xor
// ((W[7] shr 18) or (W[7] shl 14)) xor (W[7] shr 3)) + W[6];
MOV ESI,[RDI].W4
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W7
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W15
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W6
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W6,ESI
// t1:= b + (((g shr 6) or (g shl 26)) xor ((g shr 11) or (g shl 21)) xor
// ((g shr 25) or (g shl 7))) + ((g and h) xor (not g and a)) + $5cb0a9dc + W[6];
MOV EAX,R14D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R15D
NOT EAX
AND EAX,R8D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$5cb0a9dc
ADD EBX,R9D
// t2:= (((c shr 2) or (c shl 30)) xor ((c shr 13) or (c shl 19)) xor
// ((c shr 22) xor (c shl 10))) + ((c and d) xor (c and e) xor (d and e));
MOV EAX,R10D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R11D
MOV EBP,R12D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// b:= t1 + t2;
// f:= f + t1;
ADD R13D,EBX
ADD EAX,EBX
MOV R9D,EAX
// W[7]:= (((W[5] shr 17) or (W[5] shl 15)) xor
// ((W[5] shr 19) or (W[5] shl 13)) xor (W[5] shr 10)) + W[0] +
// (((W[8] shr 7) or (W[8] shl 25)) xor
// ((W[8] shr 18) or (W[8] shl 14)) xor (W[8] shr 3)) + W[7];
MOV ESI,[RDI].W5
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W8
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W0
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W7
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W7,ESI
// t1:= a + (((f shr 6) or (f shl 26)) xor ((f shr 11) or (f shl 21)) xor
// ((f shr 25) or (f shl 7))) + ((f and g) xor (not f and h)) + $76f988da + W[7];
MOV EAX,R13D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R14D
NOT EAX
AND EAX,R15D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$76f988da
ADD EBX,R8D
// t2:= (((b shr 2) or (b shl 30)) xor ((b shr 13) or (b shl 19)) xor
// ((b shr 22) xor (b shl 10))) + ((b and c) xor (b and d) xor (c and d));
MOV EAX,R9D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R10D
MOV EBP,R11D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// a:= t1 + t2;
// e:= e + t1;
ADD R12D,EBX
ADD EAX,EBX
MOV R8D,EAX
// W[8]:= (((W[6] shr 17) or (W[6] shl 15)) xor
// ((W[6] shr 19) or (W[6] shl 13)) xor (W[6] shr 10)) + W[1] +
// (((W[9] shr 7) or (W[9] shl 25)) xor
// ((W[9] shr 18) or (W[9] shl 14)) xor (W[9] shr 3)) + W[8];
MOV ESI,[RDI].W6
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W9
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W1
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W8
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W8,ESI
// t1:= h + (((e shr 6) or (e shl 26)) xor ((e shr 11) or (e shl 21)) xor
// ((e shr 25) or (e shl 7))) + ((e and f) xor (not e and g)) + $983e5152 + W[8];
MOV EAX,R12D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R13D
NOT EAX
AND EAX,R14D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$983e5152
ADD EBX,R15D
// t2:= (((a shr 2) or (a shl 30)) xor ((a shr 13) or (a shl 19)) xor
// ((a shr 22) xor (a shl 10))) + ((a and b) xor (a and c) xor (b and c));
MOV EAX,R8D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R9D
MOV EBP,R10D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// h:= t1 + t2;
// d:= d + t1;
ADD R11D,EBX
ADD EAX,EBX
MOV R15D,EAX
// W[9]:= (((W[7] shr 17) or (W[7] shl 15)) xor
// ((W[7] shr 19) or (W[7] shl 13)) xor (W[7] shr 10)) + W[2] +
// (((W[10] shr 7) or (W[10] shl 25)) xor
// ((W[10] shr 18) or (W[10] shl 14)) xor (W[10] shr 3)) + W[9];
MOV ESI,[RDI].W7
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W10
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W2
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W9
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W9,ESI
// t1:= g + (((d shr 6) or (d shl 26)) xor ((d shr 11) or (d shl 21)) xor
// ((d shr 25) or (d shl 7))) + ((d and e) xor (not d and f)) + $a831c66d + W[9];
MOV EAX,R11D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R12D
NOT EAX
AND EAX,R13D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$a831c66d
ADD EBX,R14D
// t2:= (((h shr 2) or (h shl 30)) xor ((h shr 13) or (h shl 19)) xor
// ((h shr 22) xor (h shl 10))) + ((h and a) xor (h and b) xor (a and b));
MOV EAX,R15D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R8D
MOV EBP,R9D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// g:= t1 + t2;
// c:= c + t1;
ADD R10D,EBX
ADD EAX,EBX
MOV R14D,EAX
// W[10]:= (((W[8] shr 17) or (W[8] shl 15)) xor
// ((W[8] shr 19) or (W[8] shl 13)) xor (W[8] shr 10)) + W[3] +
// (((W[11] shr 7) or (W[11] shl 25)) xor
// ((W[11] shr 18) or (W[11] shl 14)) xor (W[11] shr 3)) + W[10];
MOV ESI,[RDI].W8
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W11
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W3
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W10
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W10,ESI
// t1:= f + (((c shr 6) or (c shl 26)) xor ((c shr 11) or (c shl 21)) xor
// ((c shr 25) or (c shl 7))) + ((c and d) xor (not c and e)) + $b00327c8 + W[10];
MOV EAX,R10D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R11D
NOT EAX
AND EAX,R12D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$b00327c8
ADD EBX,R13D
// t2:= (((g shr 2) or (g shl 30)) xor ((g shr 13) or (g shl 19)) xor
// ((g shr 22) xor (g shl 10))) + ((g and h) xor (g and a) xor (h and a));
MOV EAX,R14D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R15D
MOV EBP,R8D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// f:= t1 + t2;
// b:= b + t1;
ADD R9D,EBX
ADD EAX,EBX
MOV R13D,EAX
// W[11]:= (((W[9] shr 17) or (W[9] shl 15)) xor
// ((W[9] shr 19) or (W[9] shl 13)) xor (W[9] shr 10)) + W[4] +
// (((W[12] shr 7) or (W[12] shl 25)) xor
// ((W[12] shr 18) or (W[12] shl 14)) xor (W[12] shr 3)) + W[11];
MOV ESI,[RDI].W9
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W12
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W4
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W11
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W11,ESI
// t1:= e + (((b shr 6) or (b shl 26)) xor ((b shr 11) or (b shl 21)) xor
// ((b shr 25) or (b shl 7))) + ((b and c) xor (not b and d)) + $bf597fc7 + W[11];
MOV EAX,R9D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R10D
NOT EAX
AND EAX,R11D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$bf597fc7
ADD EBX,R12D
// t2:= (((f shr 2) or (f shl 30)) xor ((f shr 13) or (f shl 19)) xor
// ((f shr 22) xor (f shl 10))) + ((f and g) xor (f and h) xor (g and h));
MOV EAX,R13D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R14D
MOV EBP,R15D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// e:= t1 + t2;
// a:= a + t1;
ADD R8D,EBX
ADD EAX,EBX
MOV R12D,EAX
// W[12]:= (((W[10] shr 17) or (W[10] shl 15)) xor
// ((W[10] shr 19) or (W[10] shl 13)) xor (W[10] shr 10)) + W[5] +
// (((W[13] shr 7) or (W[13] shl 25)) xor
// ((W[13] shr 18) or (W[13] shl 14)) xor (W[13] shr 3)) + W[12];
MOV ESI,[RDI].W10
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W13
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W5
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W12
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W12,ESI
// t1:= d + (((a shr 6) or (a shl 26)) xor ((a shr 11) or (a shl 21)) xor
// ((a shr 25) or (a shl 7))) + ((a and b) xor (not a and c)) + $c6e00bf3 + W[12];
MOV EAX,R8D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R9D
NOT EAX
AND EAX,R10D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$c6e00bf3
ADD EBX,R11D
// t2:= (((e shr 2) or (e shl 30)) xor ((e shr 13) or (e shl 19)) xor
// ((e shr 22) xor (e shl 10))) + ((e and f) xor (e and g) xor (f and g));
MOV EAX,R12D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R13D
MOV EBP,R14D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// d:= t1 + t2;
// h:= h + t1;
ADD R15D,EBX
ADD EAX,EBX
MOV R11D,EAX
// W[13]:= (((W[11] shr 17) or (W[11] shl 15)) xor
// ((W[11] shr 19) or (W[11] shl 13)) xor (W[11] shr 10)) + W[6] +
// (((W[14] shr 7) or (W[14] shl 25)) xor
// ((W[14] shr 18) or (W[14] shl 14)) xor (W[14] shr 3)) + W[13];
MOV ESI,[RDI].W11
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W14
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W6
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W13
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W13,ESI
// t1:= c + (((h shr 6) or (h shl 26)) xor ((h shr 11) or (h shl 21)) xor
// ((h shr 25) or (h shl 7))) + ((h and a) xor (not h and b)) + $d5a79147 + W[13];
MOV EAX,R15D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R8D
NOT EAX
AND EAX,R9D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$d5a79147
ADD EBX,R10D
// t2:= (((d shr 2) or (d shl 30)) xor ((d shr 13) or (d shl 19)) xor
// ((d shr 22) xor (d shl 10))) + ((d and e) xor (d and f) xor (e and f));
MOV EAX,R11D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R12D
MOV EBP,R13D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// c:= t1 + t2;
// g:= g + t1;
ADD R14D,EBX
ADD EAX,EBX
MOV R10D,EAX
// W[14]:= (((W[12] shr 17) or (W[12] shl 15)) xor
// ((W[12] shr 19) or (W[12] shl 13)) xor (W[12] shr 10)) + W[7] +
// (((W[15] shr 7) or (W[15] shl 25)) xor
// ((W[15] shr 18) or (W[15] shl 14)) xor (W[15] shr 3)) + W[14];
MOV ESI,[RDI].W12
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W15
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W7
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W14
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W14,ESI
// t1:= b + (((g shr 6) or (g shl 26)) xor ((g shr 11) or (g shl 21)) xor
// ((g shr 25) or (g shl 7))) + ((g and h) xor (not g and a)) + $06ca6351 + W[14];
MOV EAX,R14D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R15D
NOT EAX
AND EAX,R8D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$06ca6351
ADD EBX,R9D
// t2:= (((c shr 2) or (c shl 30)) xor ((c shr 13) or (c shl 19)) xor
// ((c shr 22) xor (c shl 10))) + ((c and d) xor (c and e) xor (d and e));
MOV EAX,R10D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R11D
MOV EBP,R12D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// b:= t1 + t2;
// f:= f + t1;
ADD R13D,EBX
ADD EAX,EBX
MOV R9D,EAX
// W[15]:= (((W[13] shr 17) or (W[13] shl 15)) xor
// ((W[13] shr 19) or (W[13] shl 13)) xor (W[13] shr 10)) + W[8] +
// (((W[0] shr 7) or (W[0] shl 25)) xor
// ((W[0] shr 18) or (W[0] shl 14)) xor (W[0] shr 3)) + W[15];
MOV ESI,[RDI].W13
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W0
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W8
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W15
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W15,ESI
// t1:= a + (((f shr 6) or (f shl 26)) xor ((f shr 11) or (f shl 21)) xor
// ((f shr 25) or (f shl 7))) + ((f and g) xor (not f and h)) + $14292967 + W[15];
MOV EAX,R13D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R14D
NOT EAX
AND EAX,R15D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$14292967
ADD EBX,R8D
// t2:= (((b shr 2) or (b shl 30)) xor ((b shr 13) or (b shl 19)) xor
// ((b shr 22) xor (b shl 10))) + ((b and c) xor (b and d) xor (c and d));
MOV EAX,R9D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R10D
MOV EBP,R11D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// a:= t1 + t2;
// e:= e + t1;
ADD R12D,EBX
ADD EAX,EBX
MOV R8D,EAX
// W[0]:= (((W[14] shr 17) or (W[14] shl 15)) xor
// ((W[14] shr 19) or (W[14] shl 13)) xor (W[14] shr 10)) + W[9] +
// (((W[1] shr 7) or (W[1] shl 25)) xor
// ((W[1] shr 18) or (W[1] shl 14)) xor (W[1] shr 3)) + W[0];
MOV ESI,[RDI].W14
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W1
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W9
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W0
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W0,ESI
// t1:= h + (((e shr 6) or (e shl 26)) xor ((e shr 11) or (e shl 21)) xor
// ((e shr 25) or (e shl 7))) + ((e and f) xor (not e and g)) + $27b70a85 + W[0];
MOV EAX,R12D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R13D
NOT EAX
AND EAX,R14D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$27b70a85
ADD EBX,R15D
// t2:= (((a shr 2) or (a shl 30)) xor ((a shr 13) or (a shl 19)) xor
// ((a shr 22) xor (a shl 10))) + ((a and b) xor (a and c) xor (b and c));
MOV EAX,R8D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R9D
MOV EBP,R10D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// h:= t1 + t2;
// d:= d + t1;
ADD R11D,EBX
ADD EAX,EBX
MOV R15D,EAX
// W[1]:= (((W[15] shr 17) or (W[15] shl 15)) xor
// ((W[15] shr 19) or (W[15] shl 13)) xor (W[15] shr 10)) + W[10] +
// (((W[2] shr 7) or (W[2] shl 25)) xor
// ((W[2] shr 18) or (W[2] shl 14)) xor (W[2] shr 3)) + W[1];
MOV ESI,[RDI].W15
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W2
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W10
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W1
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W1,ESI
// t1:= g + (((d shr 6) or (d shl 26)) xor ((d shr 11) or (d shl 21)) xor
// ((d shr 25) or (d shl 7))) + ((d and e) xor (not d and f)) + $2e1b2138 + W[1];
MOV EAX,R11D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R12D
NOT EAX
AND EAX,R13D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$2e1b2138
ADD EBX,R14D
// t2:= (((h shr 2) or (h shl 30)) xor ((h shr 13) or (h shl 19)) xor
// ((h shr 22) xor (h shl 10))) + ((h and a) xor (h and b) xor (a and b));
MOV EAX,R15D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R8D
MOV EBP,R9D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// g:= t1 + t2;
// c:= c + t1;
ADD R10D,EBX
ADD EAX,EBX
MOV R14D,EAX
// W[2]:= (((W[0] shr 17) or (W[0] shl 15)) xor
// ((W[0] shr 19) or (W[0] shl 13)) xor (W[0] shr 10)) + W[11] +
// (((W[3] shr 7) or (W[3] shl 25)) xor
// ((W[3] shr 18) or (W[3] shl 14)) xor (W[3] shr 3)) + W[2];
MOV ESI,[RDI].W0
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W3
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W11
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W2
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W2,ESI
// t1:= f + (((c shr 6) or (c shl 26)) xor ((c shr 11) or (c shl 21)) xor
// ((c shr 25) or (c shl 7))) + ((c and d) xor (not c and e)) + $4d2c6dfc + W[2];
MOV EAX,R10D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R11D
NOT EAX
AND EAX,R12D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$4d2c6dfc
ADD EBX,R13D
// t2:= (((g shr 2) or (g shl 30)) xor ((g shr 13) or (g shl 19)) xor
// ((g shr 22) xor (g shl 10))) + ((g and h) xor (g and a) xor (h and a));
MOV EAX,R14D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R15D
MOV EBP,R8D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// f:= t1 + t2;
// b:= b + t1;
ADD R9D,EBX
ADD EAX,EBX
MOV R13D,EAX
// W[3]:= (((W[1] shr 17) or (W[1] shl 15)) xor
// ((W[1] shr 19) or (W[1] shl 13)) xor (W[1] shr 10)) + W[12] +
// (((W[4] shr 7) or (W[4] shl 25)) xor
// ((W[4] shr 18) or (W[4] shl 14)) xor (W[4] shr 3)) + W[3];
MOV ESI,[RDI].W1
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W4
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W12
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W3
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W3,ESI
// t1:= e + (((b shr 6) or (b shl 26)) xor ((b shr 11) or (b shl 21)) xor
// ((b shr 25) or (b shl 7))) + ((b and c) xor (not b and d)) + $53380d13 + W[3];
MOV EAX,R9D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R10D
NOT EAX
AND EAX,R11D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$53380d13
ADD EBX,R12D
// t2:= (((f shr 2) or (f shl 30)) xor ((f shr 13) or (f shl 19)) xor
// ((f shr 22) xor (f shl 10))) + ((f and g) xor (f and h) xor (g and h));
MOV EAX,R13D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R14D
MOV EBP,R15D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// e:= t1 + t2;
// a:= a + t1;
ADD R8D,EBX
ADD EAX,EBX
MOV R12D,EAX
// W[4]:= (((W[2] shr 17) or (W[2] shl 15)) xor
// ((W[2] shr 19) or (W[2] shl 13)) xor (W[2] shr 10)) + W[13] +
// (((W[5] shr 7) or (W[5] shl 25)) xor
// ((W[5] shr 18) or (W[5] shl 14)) xor (W[5] shr 3)) + W[4];
MOV ESI,[RDI].W2
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W5
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W13
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W4
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W4,ESI
// t1:= d + (((a shr 6) or (a shl 26)) xor ((a shr 11) or (a shl 21)) xor
// ((a shr 25) or (a shl 7))) + ((a and b) xor (not a and c)) + $650a7354 + W[4];
MOV EAX,R8D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R9D
NOT EAX
AND EAX,R10D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$650a7354
ADD EBX,R11D
// t2:= (((e shr 2) or (e shl 30)) xor ((e shr 13) or (e shl 19)) xor
// ((e shr 22) xor (e shl 10))) + ((e and f) xor (e and g) xor (f and g));
MOV EAX,R12D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R13D
MOV EBP,R14D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// d:= t1 + t2;
// h:= h + t1;
ADD R15D,EBX
ADD EAX,EBX
MOV R11D,EAX
// W[5]:= (((W[3] shr 17) or (W[3] shl 15)) xor
// ((W[3] shr 19) or (W[3] shl 13)) xor (W[3] shr 10)) + W[14] +
// (((W[6] shr 7) or (W[6] shl 25)) xor
// ((W[6] shr 18) or (W[6] shl 14)) xor (W[6] shr 3)) + W[5];
MOV ESI,[RDI].W3
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W6
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W14
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W5
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W5,ESI
// t1:= c + (((h shr 6) or (h shl 26)) xor ((h shr 11) or (h shl 21)) xor
// ((h shr 25) or (h shl 7))) + ((h and a) xor (not h and b)) + $766a0abb + W[5];
MOV EAX,R15D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R8D
NOT EAX
AND EAX,R9D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$766a0abb
ADD EBX,R10D
// t2:= (((d shr 2) or (d shl 30)) xor ((d shr 13) or (d shl 19)) xor
// ((d shr 22) xor (d shl 10))) + ((d and e) xor (d and f) xor (e and f));
MOV EAX,R11D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R12D
MOV EBP,R13D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// c:= t1 + t2;
// g:= g + t1;
ADD R14D,EBX
ADD EAX,EBX
MOV R10D,EAX
// W[6]:= (((W[4] shr 17) or (W[4] shl 15)) xor
// ((W[4] shr 19) or (W[4] shl 13)) xor (W[4] shr 10)) + W[15] +
// (((W[7] shr 7) or (W[7] shl 25)) xor
// ((W[7] shr 18) or (W[7] shl 14)) xor (W[7] shr 3)) + W[6];
MOV ESI,[RDI].W4
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W7
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W15
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W6
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W6,ESI
// t1:= b + (((g shr 6) or (g shl 26)) xor ((g shr 11) or (g shl 21)) xor
// ((g shr 25) or (g shl 7))) + ((g and h) xor (not g and a)) + $81c2c92e + W[6];
MOV EAX,R14D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R15D
NOT EAX
AND EAX,R8D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$81c2c92e
ADD EBX,R9D
// t2:= (((c shr 2) or (c shl 30)) xor ((c shr 13) or (c shl 19)) xor
// ((c shr 22) xor (c shl 10))) + ((c and d) xor (c and e) xor (d and e));
MOV EAX,R10D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R11D
MOV EBP,R12D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// b:= t1 + t2;
// f:= f + t1;
ADD R13D,EBX
ADD EAX,EBX
MOV R9D,EAX
// W[7]:= (((W[5] shr 17) or (W[5] shl 15)) xor
// ((W[5] shr 19) or (W[5] shl 13)) xor (W[5] shr 10)) + W[0] +
// (((W[8] shr 7) or (W[8] shl 25)) xor
// ((W[8] shr 18) or (W[8] shl 14)) xor (W[8] shr 3)) + W[7];
MOV ESI,[RDI].W5
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W8
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W0
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W7
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W7,ESI
// t1:= a + (((f shr 6) or (f shl 26)) xor ((f shr 11) or (f shl 21)) xor
// ((f shr 25) or (f shl 7))) + ((f and g) xor (not f and h)) + $92722c85 + W[7];
MOV EAX,R13D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R14D
NOT EAX
AND EAX,R15D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$92722c85
ADD EBX,R8D
// t2:= (((b shr 2) or (b shl 30)) xor ((b shr 13) or (b shl 19)) xor
// ((b shr 22) xor (b shl 10))) + ((b and c) xor (b and d) xor (c and d));
MOV EAX,R9D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R10D
MOV EBP,R11D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// a:= t1 + t2;
// e:= e + t1;
ADD R12D,EBX
ADD EAX,EBX
MOV R8D,EAX
// W[8]:= (((W[6] shr 17) or (W[6] shl 15)) xor
// ((W[6] shr 19) or (W[6] shl 13)) xor (W[6] shr 10)) + W[1] +
// (((W[9] shr 7) or (W[9] shl 25)) xor
// ((W[9] shr 18) or (W[9] shl 14)) xor (W[9] shr 3)) + W[8];
MOV ESI,[RDI].W6
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W9
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W1
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W8
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W8,ESI
// t1:= h + (((e shr 6) or (e shl 26)) xor ((e shr 11) or (e shl 21)) xor
// ((e shr 25) or (e shl 7))) + ((e and f) xor (not e and g)) + $a2bfe8a1 + W[8];
MOV EAX,R12D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R13D
NOT EAX
AND EAX,R14D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$a2bfe8a1
ADD EBX,R15D
// t2:= (((a shr 2) or (a shl 30)) xor ((a shr 13) or (a shl 19)) xor
// ((a shr 22) xor (a shl 10))) + ((a and b) xor (a and c) xor (b and c));
MOV EAX,R8D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R9D
MOV EBP,R10D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// h:= t1 + t2;
// d:= d + t1;
ADD R11D,EBX
ADD EAX,EBX
MOV R15D,EAX
// W[9]:= (((W[7] shr 17) or (W[7] shl 15)) xor
// ((W[7] shr 19) or (W[7] shl 13)) xor (W[7] shr 10)) + W[2] +
// (((W[10] shr 7) or (W[10] shl 25)) xor
// ((W[10] shr 18) or (W[10] shl 14)) xor (W[10] shr 3)) + W[9];
MOV ESI,[RDI].W7
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W10
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W2
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W9
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W9,ESI
// t1:= g + (((d shr 6) or (d shl 26)) xor ((d shr 11) or (d shl 21)) xor
// ((d shr 25) or (d shl 7))) + ((d and e) xor (not d and f)) + $a81a664b + W[9];
MOV EAX,R11D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R12D
NOT EAX
AND EAX,R13D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$a81a664b
ADD EBX,R14D
// t2:= (((h shr 2) or (h shl 30)) xor ((h shr 13) or (h shl 19)) xor
// ((h shr 22) xor (h shl 10))) + ((h and a) xor (h and b) xor (a and b));
MOV EAX,R15D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R8D
MOV EBP,R9D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// g:= t1 + t2;
// c:= c + t1;
ADD R10D,EBX
ADD EAX,EBX
MOV R14D,EAX
// W[10]:= (((W[8] shr 17) or (W[8] shl 15)) xor
// ((W[8] shr 19) or (W[8] shl 13)) xor (W[8] shr 10)) + W[3] +
// (((W[11] shr 7) or (W[11] shl 25)) xor
// ((W[11] shr 18) or (W[11] shl 14)) xor (W[11] shr 3)) + W[10];
MOV ESI,[RDI].W8
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W11
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W3
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W10
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W10,ESI
// t1:= f + (((c shr 6) or (c shl 26)) xor ((c shr 11) or (c shl 21)) xor
// ((c shr 25) or (c shl 7))) + ((c and d) xor (not c and e)) + $c24b8b70 + W[10];
MOV EAX,R10D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R11D
NOT EAX
AND EAX,R12D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$c24b8b70
ADD EBX,R13D
// t2:= (((g shr 2) or (g shl 30)) xor ((g shr 13) or (g shl 19)) xor
// ((g shr 22) xor (g shl 10))) + ((g and h) xor (g and a) xor (h and a));
MOV EAX,R14D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R15D
MOV EBP,R8D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// f:= t1 + t2;
// b:= b + t1;
ADD R9D,EBX
ADD EAX,EBX
MOV R13D,EAX
// W[11]:= (((W[9] shr 17) or (W[9] shl 15)) xor
// ((W[9] shr 19) or (W[9] shl 13)) xor (W[9] shr 10)) + W[4] +
// (((W[12] shr 7) or (W[12] shl 25)) xor
// ((W[12] shr 18) or (W[12] shl 14)) xor (W[12] shr 3)) + W[11];
MOV ESI,[RDI].W9
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W12
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W4
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W11
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W11,ESI
// t1:= e + (((b shr 6) or (b shl 26)) xor ((b shr 11) or (b shl 21)) xor
// ((b shr 25) or (b shl 7))) + ((b and c) xor (not b and d)) + $c76c51a3 + W[11];
MOV EAX,R9D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R10D
NOT EAX
AND EAX,R11D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$c76c51a3
ADD EBX,R12D
// t2:= (((f shr 2) or (f shl 30)) xor ((f shr 13) or (f shl 19)) xor
// ((f shr 22) xor (f shl 10))) + ((f and g) xor (f and h) xor (g and h));
MOV EAX,R13D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R14D
MOV EBP,R15D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// e:= t1 + t2;
// a:= a + t1;
ADD R8D,EBX
ADD EAX,EBX
MOV R12D,EAX
// W[12]:= (((W[10] shr 17) or (W[10] shl 15)) xor
// ((W[10] shr 19) or (W[10] shl 13)) xor (W[10] shr 10)) + W[5] +
// (((W[13] shr 7) or (W[13] shl 25)) xor
// ((W[13] shr 18) or (W[13] shl 14)) xor (W[13] shr 3)) + W[12];
MOV ESI,[RDI].W10
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W13
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W5
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W12
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W12,ESI
// t1:= d + (((a shr 6) or (a shl 26)) xor ((a shr 11) or (a shl 21)) xor
// ((a shr 25) or (a shl 7))) + ((a and b) xor (not a and c)) + $d192e819 + W[12];
MOV EAX,R8D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R9D
NOT EAX
AND EAX,R10D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$d192e819
ADD EBX,R11D
// t2:= (((e shr 2) or (e shl 30)) xor ((e shr 13) or (e shl 19)) xor
// ((e shr 22) xor (e shl 10))) + ((e and f) xor (e and g) xor (f and g));
MOV EAX,R12D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R13D
MOV EBP,R14D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// d:= t1 + t2;
// h:= h + t1;
ADD R15D,EBX
ADD EAX,EBX
MOV R11D,EAX
// W[13]:= (((W[11] shr 17) or (W[11] shl 15)) xor
// ((W[11] shr 19) or (W[11] shl 13)) xor (W[11] shr 10)) + W[6] +
// (((W[14] shr 7) or (W[14] shl 25)) xor
// ((W[14] shr 18) or (W[14] shl 14)) xor (W[14] shr 3)) + W[13];
MOV ESI,[RDI].W11
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W14
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W6
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W13
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W13,ESI
// t1:= c + (((h shr 6) or (h shl 26)) xor ((h shr 11) or (h shl 21)) xor
// ((h shr 25) or (h shl 7))) + ((h and a) xor (not h and b)) + $d6990624 + W[13];
MOV EAX,R15D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R8D
NOT EAX
AND EAX,R9D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$d6990624
ADD EBX,R10D
// t2:= (((d shr 2) or (d shl 30)) xor ((d shr 13) or (d shl 19)) xor
// ((d shr 22) xor (d shl 10))) + ((d and e) xor (d and f) xor (e and f));
MOV EAX,R11D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R12D
MOV EBP,R13D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// c:= t1 + t2;
// g:= g + t1;
ADD R14D,EBX
ADD EAX,EBX
MOV R10D,EAX
// W[14]:= (((W[12] shr 17) or (W[12] shl 15)) xor
// ((W[12] shr 19) or (W[12] shl 13)) xor (W[12] shr 10)) + W[7] +
// (((W[15] shr 7) or (W[15] shl 25)) xor
// ((W[15] shr 18) or (W[15] shl 14)) xor (W[15] shr 3)) + W[14];
MOV ESI,[RDI].W12
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W15
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W7
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W14
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W14,ESI
// t1:= b + (((g shr 6) or (g shl 26)) xor ((g shr 11) or (g shl 21)) xor
// ((g shr 25) or (g shl 7))) + ((g and h) xor (not g and a)) + $f40e3585 + W[14];
MOV EAX,R14D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R15D
NOT EAX
AND EAX,R8D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$f40e3585
ADD EBX,R9D
// t2:= (((c shr 2) or (c shl 30)) xor ((c shr 13) or (c shl 19)) xor
// ((c shr 22) xor (c shl 10))) + ((c and d) xor (c and e) xor (d and e));
MOV EAX,R10D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R11D
MOV EBP,R12D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// b:= t1 + t2;
// f:= f + t1;
ADD R13D,EBX
ADD EAX,EBX
MOV R9D,EAX
// W[15]:= (((W[13] shr 17) or (W[13] shl 15)) xor
// ((W[13] shr 19) or (W[13] shl 13)) xor (W[13] shr 10)) + W[8] +
// (((W[0] shr 7) or (W[0] shl 25)) xor
// ((W[0] shr 18) or (W[0] shl 14)) xor (W[0] shr 3)) + W[15];
MOV ESI,[RDI].W13
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W0
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W8
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W15
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W15,ESI
// t1:= a + (((f shr 6) or (f shl 26)) xor ((f shr 11) or (f shl 21)) xor
// ((f shr 25) or (f shl 7))) + ((f and g) xor (not f and h)) + $106aa070 + W[15];
MOV EAX,R13D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R14D
NOT EAX
AND EAX,R15D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$106aa070
ADD EBX,R8D
// t2:= (((b shr 2) or (b shl 30)) xor ((b shr 13) or (b shl 19)) xor
// ((b shr 22) xor (b shl 10))) + ((b and c) xor (b and d) xor (c and d));
MOV EAX,R9D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R10D
MOV EBP,R11D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// a:= t1 + t2;
// e:= e + t1;
ADD R12D,EBX
ADD EAX,EBX
MOV R8D,EAX
// W[0]:= (((W[14] shr 17) or (W[14] shl 15)) xor
// ((W[14] shr 19) or (W[14] shl 13)) xor (W[14] shr 10)) + W[9] +
// (((W[1] shr 7) or (W[1] shl 25)) xor
// ((W[1] shr 18) or (W[1] shl 14)) xor (W[1] shr 3)) + W[0];
MOV ESI,[RDI].W14
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W1
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W9
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W0
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W0,ESI
// t1:= h + (((e shr 6) or (e shl 26)) xor ((e shr 11) or (e shl 21)) xor
// ((e shr 25) or (e shl 7))) + ((e and f) xor (not e and g)) + $19a4c116 + W[0];
MOV EAX,R12D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R13D
NOT EAX
AND EAX,R14D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$19a4c116
ADD EBX,R15D
// t2:= (((a shr 2) or (a shl 30)) xor ((a shr 13) or (a shl 19)) xor
// ((a shr 22) xor (a shl 10))) + ((a and b) xor (a and c) xor (b and c));
MOV EAX,R8D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R9D
MOV EBP,R10D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// h:= t1 + t2;
// d:= d + t1;
ADD R11D,EBX
ADD EAX,EBX
MOV R15D,EAX
// W[1]:= (((W[15] shr 17) or (W[15] shl 15)) xor
// ((W[15] shr 19) or (W[15] shl 13)) xor (W[15] shr 10)) + W[10] +
// (((W[2] shr 7) or (W[2] shl 25)) xor
// ((W[2] shr 18) or (W[2] shl 14)) xor (W[2] shr 3)) + W[1];
MOV ESI,[RDI].W15
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W2
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W10
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W1
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W1,ESI
// t1:= g + (((d shr 6) or (d shl 26)) xor ((d shr 11) or (d shl 21)) xor
// ((d shr 25) or (d shl 7))) + ((d and e) xor (not d and f)) + $1e376c08 + W[1];
MOV EAX,R11D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R12D
NOT EAX
AND EAX,R13D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$1e376c08
ADD EBX,R14D
// t2:= (((h shr 2) or (h shl 30)) xor ((h shr 13) or (h shl 19)) xor
// ((h shr 22) xor (h shl 10))) + ((h and a) xor (h and b) xor (a and b));
MOV EAX,R15D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R8D
MOV EBP,R9D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// g:= t1 + t2;
// c:= c + t1;
ADD R10D,EBX
ADD EAX,EBX
MOV R14D,EAX
// W[2]:= (((W[0] shr 17) or (W[0] shl 15)) xor
// ((W[0] shr 19) or (W[0] shl 13)) xor (W[0] shr 10)) + W[11] +
// (((W[3] shr 7) or (W[3] shl 25)) xor
// ((W[3] shr 18) or (W[3] shl 14)) xor (W[3] shr 3)) + W[2];
MOV ESI,[RDI].W0
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W3
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W11
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W2
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W2,ESI
// t1:= f + (((c shr 6) or (c shl 26)) xor ((c shr 11) or (c shl 21)) xor
// ((c shr 25) or (c shl 7))) + ((c and d) xor (not c and e)) + $2748774c + W[2];
MOV EAX,R10D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R11D
NOT EAX
AND EAX,R12D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$2748774c
ADD EBX,R13D
// t2:= (((g shr 2) or (g shl 30)) xor ((g shr 13) or (g shl 19)) xor
// ((g shr 22) xor (g shl 10))) + ((g and h) xor (g and a) xor (h and a));
MOV EAX,R14D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R15D
MOV EBP,R8D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// f:= t1 + t2;
// b:= b + t1;
ADD R9D,EBX
ADD EAX,EBX
MOV R13D,EAX
// W[3]:= (((W[1] shr 17) or (W[1] shl 15)) xor
// ((W[1] shr 19) or (W[1] shl 13)) xor (W[1] shr 10)) + W[12] +
// (((W[4] shr 7) or (W[4] shl 25)) xor
// ((W[4] shr 18) or (W[4] shl 14)) xor (W[4] shr 3)) + W[3];
MOV ESI,[RDI].W1
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W4
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W12
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W3
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W3,ESI
// t1:= e + (((b shr 6) or (b shl 26)) xor ((b shr 11) or (b shl 21)) xor
// ((b shr 25) or (b shl 7))) + ((b and c) xor (not b and d)) + $34b0bcb5 + W[3];
MOV EAX,R9D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R10D
NOT EAX
AND EAX,R11D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$34b0bcb5
ADD EBX,R12D
// t2:= (((f shr 2) or (f shl 30)) xor ((f shr 13) or (f shl 19)) xor
// ((f shr 22) xor (f shl 10))) + ((f and g) xor (f and h) xor (g and h));
MOV EAX,R13D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R14D
MOV EBP,R15D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// e:= t1 + t2;
// a:= a + t1;
ADD R8D,EBX
ADD EAX,EBX
MOV R12D,EAX
// W[4]:= (((W[2] shr 17) or (W[2] shl 15)) xor
// ((W[2] shr 19) or (W[2] shl 13)) xor (W[2] shr 10)) + W[13] +
// (((W[5] shr 7) or (W[5] shl 25)) xor
// ((W[5] shr 18) or (W[5] shl 14)) xor (W[5] shr 3)) + W[4];
MOV ESI,[RDI].W2
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W5
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W13
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W4
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W4,ESI
// t1:= d + (((a shr 6) or (a shl 26)) xor ((a shr 11) or (a shl 21)) xor
// ((a shr 25) or (a shl 7))) + ((a and b) xor (not a and c)) + $391c0cb3 + W[4];
MOV EAX,R8D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R9D
NOT EAX
AND EAX,R10D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$391c0cb3
ADD EBX,R11D
// t2:= (((e shr 2) or (e shl 30)) xor ((e shr 13) or (e shl 19)) xor
// ((e shr 22) xor (e shl 10))) + ((e and f) xor (e and g) xor (f and g));
MOV EAX,R12D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R13D
MOV EBP,R14D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// d:= t1 + t2;
// h:= h + t1;
ADD R15D,EBX
ADD EAX,EBX
MOV R11D,EAX
// W[5]:= (((W[3] shr 17) or (W[3] shl 15)) xor
// ((W[3] shr 19) or (W[3] shl 13)) xor (W[3] shr 10)) + W[14] +
// (((W[6] shr 7) or (W[6] shl 25)) xor
// ((W[6] shr 18) or (W[6] shl 14)) xor (W[6] shr 3)) + W[5];
MOV ESI,[RDI].W3
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W6
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W14
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W5
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W5,ESI
// t1:= c + (((h shr 6) or (h shl 26)) xor ((h shr 11) or (h shl 21)) xor
// ((h shr 25) or (h shl 7))) + ((h and a) xor (not h and b)) + $4ed8aa4a + W[5];
MOV EAX,R15D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R8D
NOT EAX
AND EAX,R9D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$4ed8aa4a
ADD EBX,R10D
// t2:= (((d shr 2) or (d shl 30)) xor ((d shr 13) or (d shl 19)) xor
// ((d shr 22) xor (d shl 10))) + ((d and e) xor (d and f) xor (e and f));
MOV EAX,R11D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R12D
MOV EBP,R13D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// c:= t1 + t2;
// g:= g + t1;
ADD R14D,EBX
ADD EAX,EBX
MOV R10D,EAX
// W[6]:= (((W[4] shr 17) or (W[4] shl 15)) xor
// ((W[4] shr 19) or (W[4] shl 13)) xor (W[4] shr 10)) + W[15] +
// (((W[7] shr 7) or (W[7] shl 25)) xor
// ((W[7] shr 18) or (W[7] shl 14)) xor (W[7] shr 3)) + W[6];
MOV ESI,[RDI].W4
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W7
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W15
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W6
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W6,ESI
// t1:= b + (((g shr 6) or (g shl 26)) xor ((g shr 11) or (g shl 21)) xor
// ((g shr 25) or (g shl 7))) + ((g and h) xor (not g and a)) + $5b9cca4f + W[6];
MOV EAX,R14D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R15D
NOT EAX
AND EAX,R8D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$5b9cca4f
ADD EBX,R9D
// t2:= (((c shr 2) or (c shl 30)) xor ((c shr 13) or (c shl 19)) xor
// ((c shr 22) xor (c shl 10))) + ((c and d) xor (c and e) xor (d and e));
MOV EAX,R10D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R11D
MOV EBP,R12D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// b:= t1 + t2;
// f:= f + t1;
ADD R13D,EBX
ADD EAX,EBX
MOV R9D,EAX
// W[7]:= (((W[5] shr 17) or (W[5] shl 15)) xor
// ((W[5] shr 19) or (W[5] shl 13)) xor (W[5] shr 10)) + W[0] +
// (((W[8] shr 7) or (W[8] shl 25)) xor
// ((W[8] shr 18) or (W[8] shl 14)) xor (W[8] shr 3)) + W[7];
MOV ESI,[RDI].W5
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W8
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W0
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W7
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W7,ESI
// t1:= a + (((f shr 6) or (f shl 26)) xor ((f shr 11) or (f shl 21)) xor
// ((f shr 25) or (f shl 7))) + ((f and g) xor (not f and h)) + $682e6ff3 + W[7];
MOV EAX,R13D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R14D
NOT EAX
AND EAX,R15D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$682e6ff3
ADD EBX,R8D
// t2:= (((b shr 2) or (b shl 30)) xor ((b shr 13) or (b shl 19)) xor
// ((b shr 22) xor (b shl 10))) + ((b and c) xor (b and d) xor (c and d));
MOV EAX,R9D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R10D
MOV EBP,R11D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// a:= t1 + t2;
// e:= e + t1;
ADD R12D,EBX
ADD EAX,EBX
MOV R8D,EAX
// W[8]:= (((W[6] shr 17) or (W[6] shl 15)) xor
// ((W[6] shr 19) or (W[6] shl 13)) xor (W[6] shr 10)) + W[1] +
// (((W[9] shr 7) or (W[9] shl 25)) xor
// ((W[9] shr 18) or (W[9] shl 14)) xor (W[9] shr 3)) + W[8];
MOV ESI,[RDI].W6
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W9
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W1
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W8
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W8,ESI
// t1:= h + (((e shr 6) or (e shl 26)) xor ((e shr 11) or (e shl 21)) xor
// ((e shr 25) or (e shl 7))) + ((e and f) xor (not e and g)) + $748f82ee + W[8];
MOV EAX,R12D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R13D
NOT EAX
AND EAX,R14D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$748f82ee
ADD EBX,R15D
// t2:= (((a shr 2) or (a shl 30)) xor ((a shr 13) or (a shl 19)) xor
// ((a shr 22) xor (a shl 10))) + ((a and b) xor (a and c) xor (b and c));
MOV EAX,R8D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R9D
MOV EBP,R10D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// h:= t1 + t2;
// d:= d + t1;
ADD R11D,EBX
ADD EAX,EBX
MOV R15D,EAX
// W[9]:= (((W[7] shr 17) or (W[7] shl 15)) xor
// ((W[7] shr 19) or (W[7] shl 13)) xor (W[7] shr 10)) + W[2] +
// (((W[10] shr 7) or (W[10] shl 25)) xor
// ((W[10] shr 18) or (W[10] shl 14)) xor (W[10] shr 3)) + W[9];
MOV ESI,[RDI].W7
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W10
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W2
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W9
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W9,ESI
// t1:= g + (((d shr 6) or (d shl 26)) xor ((d shr 11) or (d shl 21)) xor
// ((d shr 25) or (d shl 7))) + ((d and e) xor (not d and f)) + $78a5636f + W[9];
MOV EAX,R11D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R12D
NOT EAX
AND EAX,R13D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$78a5636f
ADD EBX,R14D
// t2:= (((h shr 2) or (h shl 30)) xor ((h shr 13) or (h shl 19)) xor
// ((h shr 22) xor (h shl 10))) + ((h and a) xor (h and b) xor (a and b));
MOV EAX,R15D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R8D
MOV EBP,R9D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// g:= t1 + t2;
// c:= c + t1;
ADD R10D,EBX
ADD EAX,EBX
MOV R14D,EAX
// W[10]:= (((W[8] shr 17) or (W[8] shl 15)) xor
// ((W[8] shr 19) or (W[8] shl 13)) xor (W[8] shr 10)) + W[3] +
// (((W[11] shr 7) or (W[11] shl 25)) xor
// ((W[11] shr 18) or (W[11] shl 14)) xor (W[11] shr 3)) + W[10];
MOV ESI,[RDI].W8
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W11
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W3
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W10
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W10,ESI
// t1:= f + (((c shr 6) or (c shl 26)) xor ((c shr 11) or (c shl 21)) xor
// ((c shr 25) or (c shl 7))) + ((c and d) xor (not c and e)) + $84c87814 + W[10];
MOV EAX,R10D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R11D
NOT EAX
AND EAX,R12D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$84c87814
ADD EBX,R13D
// t2:= (((g shr 2) or (g shl 30)) xor ((g shr 13) or (g shl 19)) xor
// ((g shr 22) xor (g shl 10))) + ((g and h) xor (g and a) xor (h and a));
MOV EAX,R14D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R15D
MOV EBP,R8D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// f:= t1 + t2;
// b:= b + t1;
ADD R9D,EBX
ADD EAX,EBX
MOV R13D,EAX
// W[11]:= (((W[9] shr 17) or (W[9] shl 15)) xor
// ((W[9] shr 19) or (W[9] shl 13)) xor (W[9] shr 10)) + W[4] +
// (((W[12] shr 7) or (W[12] shl 25)) xor
// ((W[12] shr 18) or (W[12] shl 14)) xor (W[12] shr 3)) + W[11];
MOV ESI,[RDI].W9
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W12
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W4
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W11
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W11,ESI
// t1:= e + (((b shr 6) or (b shl 26)) xor ((b shr 11) or (b shl 21)) xor
// ((b shr 25) or (b shl 7))) + ((b and c) xor (not b and d)) + $8cc70208 + W[11];
MOV EAX,R9D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R10D
NOT EAX
AND EAX,R11D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$8cc70208
ADD EBX,R12D
// t2:= (((f shr 2) or (f shl 30)) xor ((f shr 13) or (f shl 19)) xor
// ((f shr 22) xor (f shl 10))) + ((f and g) xor (f and h) xor (g and h));
MOV EAX,R13D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R14D
MOV EBP,R15D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// e:= t1 + t2;
// a:= a + t1;
ADD R8D,EBX
ADD EAX,EBX
MOV R12D,EAX
// W[12]:= (((W[10] shr 17) or (W[10] shl 15)) xor
// ((W[10] shr 19) or (W[10] shl 13)) xor (W[10] shr 10)) + W[5] +
// (((W[13] shr 7) or (W[13] shl 25)) xor
// ((W[13] shr 18) or (W[13] shl 14)) xor (W[13] shr 3)) + W[12];
MOV ESI,[RDI].W10
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W13
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W5
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W12
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W12,ESI
// t1:= d + (((a shr 6) or (a shl 26)) xor ((a shr 11) or (a shl 21)) xor
// ((a shr 25) or (a shl 7))) + ((a and b) xor (not a and c)) + $90befffa + W[12];
MOV EAX,R8D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R9D
NOT EAX
AND EAX,R10D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$90befffa
ADD EBX,R11D
// t2:= (((e shr 2) or (e shl 30)) xor ((e shr 13) or (e shl 19)) xor
// ((e shr 22) xor (e shl 10))) + ((e and f) xor (e and g) xor (f and g));
MOV EAX,R12D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R13D
MOV EBP,R14D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// d:= t1 + t2;
// h:= h + t1;
ADD R15D,EBX
ADD EAX,EBX
MOV R11D,EAX
// W[13]:= (((W[11] shr 17) or (W[11] shl 15)) xor
// ((W[11] shr 19) or (W[11] shl 13)) xor (W[11] shr 10)) + W[6] +
// (((W[14] shr 7) or (W[14] shl 25)) xor
// ((W[14] shr 18) or (W[14] shl 14)) xor (W[14] shr 3)) + W[13];
MOV ESI,[RDI].W11
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W14
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W6
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W13
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W13,ESI
// t1:= c + (((h shr 6) or (h shl 26)) xor ((h shr 11) or (h shl 21)) xor
// ((h shr 25) or (h shl 7))) + ((h and a) xor (not h and b)) + $a4506ceb + W[13];
MOV EAX,R15D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R8D
NOT EAX
AND EAX,R9D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$a4506ceb
ADD EBX,R10D
// t2:= (((d shr 2) or (d shl 30)) xor ((d shr 13) or (d shl 19)) xor
// ((d shr 22) xor (d shl 10))) + ((d and e) xor (d and f) xor (e and f));
MOV EAX,R11D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R12D
MOV EBP,R13D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// c:= t1 + t2;
// g:= g + t1;
ADD R14D,EBX
ADD EAX,EBX
MOV R10D,EAX
// W[14]:= (((W[12] shr 17) or (W[12] shl 15)) xor
// ((W[12] shr 19) or (W[12] shl 13)) xor (W[12] shr 10)) + W[7] +
// (((W[15] shr 7) or (W[15] shl 25)) xor
// ((W[15] shr 18) or (W[15] shl 14)) xor (W[15] shr 3)) + W[14];
MOV ESI,[RDI].W12
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W15
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W7
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W14
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W14,ESI
// t1:= b + (((g shr 6) or (g shl 26)) xor ((g shr 11) or (g shl 21)) xor
// ((g shr 25) or (g shl 7))) + ((g and h) xor (not g and a)) + $bef9a3f7 + W[14];
MOV EAX,R14D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R15D
NOT EAX
AND EAX,R8D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$bef9a3f7
ADD EBX,R9D
// t2:= (((c shr 2) or (c shl 30)) xor ((c shr 13) or (c shl 19)) xor
// ((c shr 22) xor (c shl 10))) + ((c and d) xor (c and e) xor (d and e));
MOV EAX,R10D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R11D
MOV EBP,R12D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// b:= t1 + t2;
// f:= f + t1;
ADD R13D,EBX
ADD EAX,EBX
MOV R9D,EAX
// W[15]:= (((W[13] shr 17) or (W[13] shl 15)) xor
// ((W[13] shr 19) or (W[13] shl 13)) xor (W[13] shr 10)) + W[8] +
// (((W[0] shr 7) or (W[0] shl 25)) xor
// ((W[0] shr 18) or (W[0] shl 14)) xor (W[0] shr 3)) + W[15];
MOV ESI,[RDI].W13
MOV EAX,ESI
MOV EBX,ESI
ROL ESI,15
ROL EAX,13
SHR EBX,10
XOR ESI,EAX
XOR ESI,EBX
MOV EAX,[RDI].W0
MOV EBX,EAX
MOV ECX,EAX
ADD ESI,[RDI].W8
ROR EAX,7
ROL EBX,14
SHR ECX,3
ADD ESI,[RDI].W15
XOR EAX,EBX
XOR EAX,ECX
ADD ESI,EAX
MOV [RDI].W15,ESI
// t1:= a + (((f shr 6) or (f shl 26)) xor ((f shr 11) or (f shl 21)) xor
// ((f shr 25) or (f shl 7))) + ((f and g) xor (not f and h)) + $c67178f2 + W[15];
MOV EAX,R13D
MOV EBX,EAX
MOV ECX,EAX
MOV EDX,EAX
ROR EBX,6
ROR ECX,11
ROL EDX,7
XOR EBX,ECX
XOR EBX,EDX
MOV ECX,EAX
AND ECX,R14D
NOT EAX
AND EAX,R15D
XOR EAX,ECX
ADD EBX,ESI
ADD EBX,EAX
ADD EBX,$c67178f2
ADD EBX,R8D
// t2:= (((b shr 2) or (b shl 30)) xor ((b shr 13) or (b shl 19)) xor
// ((b shr 22) xor (b shl 10))) + ((b and c) xor (b and d) xor (c and d));
MOV EAX,R9D
MOV ECX,EAX
MOV EDX,EAX
MOV ESI,EAX
ROR ECX,2
ROR EDX,13
ROL ESI,10
XOR ECX,EDX
XOR ECX,ESI
MOV EDX,EAX
MOV ESI,R10D
MOV EBP,R11D
AND EAX,ESI
AND EDX,EBP
AND ESI,EBP
XOR EAX,EDX
XOR EAX,ESI
ADD EAX,ECX
// a:= t1 + t2;
// e:= e + t1;
ADD R12D,EBX
ADD EAX,EBX
MOV R8D,EAX
ADD [RDI].DigestH,R15D
ADD [RDI].DigestG,R14D
ADD [RDI].DigestF,R13D
ADD [RDI].DigestE,R12D
ADD [RDI].DigestD,R11D
ADD [RDI].DigestC,R10D
ADD [RDI].DigestB,R9D
ADD [RDI].DigestA,R8D
XOR RAX,RAX
MOV [RDI].W0,RAX
MOV [RDI].W2,RAX
MOV [RDI].W4,RAX
MOV [RDI].W6,RAX
MOV [RDI].W8,RAX
MOV [RDI].W10,RAX
MOV [RDI].W12,RAX
MOV [RDI].W14,RAX
ADD RSP,8
POP R15
POP R14
POP R13
POP R12
POP RBP
POP RBX
POP RDI
POP RSI
end;
{$ENDIF}
class procedure TSHA256Alg.Init(Inst: PSHA256Alg);
begin
Inst.FData.Digest[0]:= $6a09e667;
Inst.FData.Digest[1]:= $bb67ae85;
Inst.FData.Digest[2]:= $3c6ef372;
Inst.FData.Digest[3]:= $a54ff53a;
Inst.FData.Digest[4]:= $510e527f;
Inst.FData.Digest[5]:= $9b05688c;
Inst.FData.Digest[6]:= $1f83d9ab;
Inst.FData.Digest[7]:= $5be0cd19;
FillChar(Inst.FData.Block, SizeOf(Inst.FData.Block), 0);
Inst.FData.Count:= 0;
end;
class procedure TSHA256Alg.Update(Inst: PSHA256Alg; Data: PByte; DataSize: Cardinal);
var
Cnt, Ofs: Cardinal;
begin
while DataSize > 0 do begin
Ofs:= Cardinal(Inst.FData.Count) and $3F;
Cnt:= $40 - Ofs;
if Cnt > DataSize then Cnt:= DataSize;
Move(Data^, PByte(@Inst.FData.Block)[Ofs], Cnt);
if (Cnt + Ofs = $40) then Inst.Compress;
Inc(Inst.FData.Count, Cnt);
Dec(DataSize, Cnt);
Inc(Data, Cnt);
end;
end;
class procedure TSHA256Alg.Done(Inst: PSHA256Alg; PDigest: PSHA256Digest);
var
Ofs: Cardinal;
begin
Ofs:= Cardinal(Inst.FData.Count) and $3F;
Inst.FData.Block[Ofs]:= $80;
if Ofs >= 56 then
Inst.Compress;
Inst.FData.Count:= Inst.FData.Count shl 3;
PUInt32(@Inst.FData.Block[56])^:= Swap32(UInt32(Inst.FData.Count shr 32));
PUInt32(@Inst.FData.Block[60])^:= Swap32(UInt32(Inst.FData.Count));
Inst.Compress;
Inst.FData.Digest[0]:= Swap32(Inst.FData.Digest[0]);
Inst.FData.Digest[1]:= Swap32(Inst.FData.Digest[1]);
Inst.FData.Digest[2]:= Swap32(Inst.FData.Digest[2]);
Inst.FData.Digest[3]:= Swap32(Inst.FData.Digest[3]);
Inst.FData.Digest[4]:= Swap32(Inst.FData.Digest[4]);
Inst.FData.Digest[5]:= Swap32(Inst.FData.Digest[5]);
Inst.FData.Digest[6]:= Swap32(Inst.FData.Digest[6]);
Inst.FData.Digest[7]:= Swap32(Inst.FData.Digest[7]);
Move(Inst.FData.Digest, PDigest^, SizeOf(TSHA256Digest));
Init(Inst);
end;
class function TSHA256Alg.GetDigestSize(Inst: PSHA256Alg): Integer;
begin
Result:= SizeOf(TSHA256Digest);
end;
class function TSHA256Alg.GetBlockSize(Inst: PSHA256Alg): Integer;
begin
Result:= 64;
end;
class function TSHA256Alg.Duplicate(Inst: PSHA256Alg; var DupInst: PSHA256Alg): TF_RESULT;
begin
Result:= GetSHA256Algorithm(DupInst);
if Result = TF_S_OK then
DupInst.FData:= Inst.FData;
end;
{ TSHA224Alg }
class procedure TSHA224Alg.Init(Inst: PSHA224Alg);
begin
Inst.FData.Digest[0]:= $c1059ed8;
Inst.FData.Digest[1]:= $367cd507;
Inst.FData.Digest[2]:= $3070dd17;
Inst.FData.Digest[3]:= $f70e5939;
Inst.FData.Digest[4]:= $ffc00b31;
Inst.FData.Digest[5]:= $68581511;
Inst.FData.Digest[6]:= $64f98fa7;
Inst.FData.Digest[7]:= $befa4fa4;
FillChar(Inst.FData.Block, SizeOf(Inst.FData.Block), 0);
Inst.FData.Count:= 0;
end;
class procedure TSHA224Alg.Done(Inst: PSHA224Alg; PDigest: PSHA224Digest);
var
Ofs: Cardinal;
begin
Ofs:= Cardinal(Inst.FData.Count) and $3F;
Inst.FData.Block[Ofs]:= $80;
if Ofs >= 56 then
PSHA256Alg(Inst).Compress;
Inst.FData.Count:= Inst.FData.Count shl 3;
PUInt32(@Inst.FData.Block[56])^:= Swap32(UInt32(Inst.FData.Count shr 32));
PUInt32(@Inst.FData.Block[60])^:= Swap32(UInt32(Inst.FData.Count));
PSHA256Alg(Inst).Compress;
Inst.FData.Digest[0]:= Swap32(Inst.FData.Digest[0]);
Inst.FData.Digest[1]:= Swap32(Inst.FData.Digest[1]);
Inst.FData.Digest[2]:= Swap32(Inst.FData.Digest[2]);
Inst.FData.Digest[3]:= Swap32(Inst.FData.Digest[3]);
Inst.FData.Digest[4]:= Swap32(Inst.FData.Digest[4]);
Inst.FData.Digest[5]:= Swap32(Inst.FData.Digest[5]);
Inst.FData.Digest[6]:= Swap32(Inst.FData.Digest[6]);
Move(Inst.FData.Digest, PDigest^, SizeOf(TSHA224Digest));
Init(Inst);
end;
class function TSHA224Alg.GetDigestSize(Inst: PSHA256Alg): Integer;
begin
Result:= SizeOf(TSHA224Digest);
end;
end.
|
unit MFichas.Model.Pagamento.Formas.Factory;
interface
uses
MFichas.Model.Pagamento.Interfaces,
MFichas.Model.Pagamento.Formas.Interfaces,
MFichas.Model.Pagamento.Formas.Dinheiro,
MFichas.Model.Pagamento.Formas.Debito,
MFichas.Model.Pagamento.Formas.Credito;
type
TModelPagamentoFormasFactory = class(TInterfacedObject, iModelPagamentoFormasFactory)
private
constructor Create;
public
destructor Destroy; override;
class function New: iModelPagamentoFormasFactory;
function Dinheiro(AParent: iModelPagamento) : iModelPagamentoMetodos;
function CartaoDebito(AParent: iModelPagamento) : iModelPagamentoMetodos;
function CartaoCredito(AParent: iModelPagamento): iModelPagamentoMetodos;
end;
implementation
{ TModelPagamentoFormasFactory }
function TModelPagamentoFormasFactory.CartaoCredito(AParent: iModelPagamento): iModelPagamentoMetodos;
begin
Result := TModelPagamentoFormasCredito.New(AParent);
end;
function TModelPagamentoFormasFactory.CartaoDebito(AParent: iModelPagamento): iModelPagamentoMetodos;
begin
Result := TModelPagamentoFormasDebito.New(AParent);
end;
constructor TModelPagamentoFormasFactory.Create;
begin
end;
destructor TModelPagamentoFormasFactory.Destroy;
begin
inherited;
end;
function TModelPagamentoFormasFactory.Dinheiro(AParent: iModelPagamento): iModelPagamentoMetodos;
begin
Result := TModelPagamentoFormasDinheiro.New(AParent);
end;
class function TModelPagamentoFormasFactory.New: iModelPagamentoFormasFactory;
begin
Result := Self.Create;
end;
end.
|
unit TTSMAPPINGSTABLE;
interface
uses
Classes, DB, DBISAMTb, SysUtils, DBISAMTableAU, DataBuf;
type
TTTSLENDRecord = record
PLenderNum: String[4];
PModCount: Integer;
PName: String[40];
PAddr1: String[40];
PAddr2: String[40];
PCity: String[25];
PState: String[2];
PZip: String[10];
PPhone: String[40];
POptions: String[99];
PAdmin: String[30];
PScreen: String[12];
PCombHeaderID: Integer;
PCombFooterID: Integer;
PFlagCaptions: String[110];
End;
TTTSLENDBuffer = class(TDataBuf)
protected
function PtrIndex(Index:integer):Pointer;override;
public
Data: TTTSLENDRecord;
function FieldNameToIndex(s:string):integer;override;
function FieldType(index:integer):TFieldType;override;
end;
TEITTSLEND = (TTSLENDPrimaryKey, TTSLENDByName);
TTTSLENDTable = class( TDBISAMTableAU )
private
FDFLenderNum: TStringField;
FDFModCount: TIntegerField;
FDFName: TStringField;
FDFAddr1: TStringField;
FDFAddr2: TStringField;
FDFCity: TStringField;
FDFState: TStringField;
FDFZip: TStringField;
FDFPhone: TStringField;
FDFOptions: TStringField;
FDFAdmin: TStringField;
FDFScreen: TStringField;
FDFCombHeaderID: TIntegerField;
FDFCombFooterID: TIntegerField;
FDFCombHeaderText: TBlobField;
FDFCombFooterText: TBlobField;
FDFCaptions: TBlobField;
FDFFlagCaptions: TStringField;
procedure SetPLenderNum(const Value: String);
function GetPLenderNum:String;
procedure SetPModCount(const Value: Integer);
function GetPModCount:Integer;
procedure SetPName(const Value: String);
function GetPName:String;
procedure SetPAddr1(const Value: String);
function GetPAddr1:String;
procedure SetPAddr2(const Value: String);
function GetPAddr2:String;
procedure SetPCity(const Value: String);
function GetPCity:String;
procedure SetPState(const Value: String);
function GetPState:String;
procedure SetPZip(const Value: String);
function GetPZip:String;
procedure SetPPhone(const Value: String);
function GetPPhone:String;
procedure SetPOptions(const Value: String);
function GetPOptions:String;
procedure SetPAdmin(const Value: String);
function GetPAdmin:String;
procedure SetPScreen(const Value: String);
function GetPScreen:String;
procedure SetPCombHeaderID(const Value: Integer);
function GetPCombHeaderID:Integer;
procedure SetPCombFooterID(const Value: Integer);
function GetPCombFooterID:Integer;
procedure SetPFlagCaptions(const Value: String);
function GetPFlagCaptions:String;
function GenerateNewFieldName( AOwner: TComponent; const DatasetName: string; const FieldName: string ): string;
procedure SetEnumIndex(Value: TEITTSLEND);
function GetEnumIndex: TEITTSLEND;
protected
function CreateField( const FieldName : string ): TField;
procedure CreateFields; reintroduce;
procedure SetActive(Value: Boolean); override;
procedure LoadFieldDefs(AStringList:TStringList);override;
procedure LoadIndexDefs(AStringList:TStringList);override;
public
function GetDataBuffer:TTTSLENDRecord;
procedure StoreDataBuffer(ABuffer:TTTSLENDRecord);
property DFLenderNum: TStringField read FDFLenderNum;
property DFModCount: TIntegerField read FDFModCount;
property DFName: TStringField read FDFName;
property DFAddr1: TStringField read FDFAddr1;
property DFAddr2: TStringField read FDFAddr2;
property DFCity: TStringField read FDFCity;
property DFState: TStringField read FDFState;
property DFZip: TStringField read FDFZip;
property DFPhone: TStringField read FDFPhone;
property DFOptions: TStringField read FDFOptions;
property DFAdmin: TStringField read FDFAdmin;
property DFScreen: TStringField read FDFScreen;
property DFCombHeaderID: TIntegerField read FDFCombHeaderID;
property DFCombFooterID: TIntegerField read FDFCombFooterID;
property DFCombHeaderText: TBlobField read FDFCombHeaderText;
property DFCombFooterText: TBlobField read FDFCombFooterText;
property DFCaptions: TBlobField read FDFCaptions;
property DFFlagCaptions: TStringField read FDFFlagCaptions;
property PLenderNum: String read GetPLenderNum write SetPLenderNum;
property PModCount: Integer read GetPModCount write SetPModCount;
property PName: String read GetPName write SetPName;
property PAddr1: String read GetPAddr1 write SetPAddr1;
property PAddr2: String read GetPAddr2 write SetPAddr2;
property PCity: String read GetPCity write SetPCity;
property PState: String read GetPState write SetPState;
property PZip: String read GetPZip write SetPZip;
property PPhone: String read GetPPhone write SetPPhone;
property POptions: String read GetPOptions write SetPOptions;
property PAdmin: String read GetPAdmin write SetPAdmin;
property PScreen: String read GetPScreen write SetPScreen;
property PCombHeaderID: Integer read GetPCombHeaderID write SetPCombHeaderID;
property PCombFooterID: Integer read GetPCombFooterID write SetPCombFooterID;
property PFlagCaptions: String read GetPFlagCaptions write SetPFlagCaptions;
published
property Active write SetActive;
property EnumIndex: TEITTSLEND read GetEnumIndex write SetEnumIndex;
end; { TTTSLENDTable }
procedure Register;
implementation
function TTTSLENDTable.GenerateNewFieldName( AOwner: TComponent; const DatasetName: string; const FieldName: string ): string;
var
I: Integer;
NewName: string;
Done: Boolean;
function ComponentExists( AOwner: TComponent; const CompName: string ): Boolean;
var
I: Integer;
begin
Result := False;
for I := 0 To AOwner.ComponentCount - 1 do
begin
if AnsiCompareText( CompName, AOwner.Components[ I ].Name ) = 0 then
begin
Result := True;
Break;
end;
end;
end; { ComponentExists }
begin { TTTSLENDTable.GenerateNewFieldName }
NewName := DatasetName;
for I := 1 to Length( FieldName ) do
begin
if FieldName[ I ] in [ '0'..'9', '_', 'A'..'Z', 'a'..'z' ] then
NewName := NewName + FieldName[ I ];
end;
if ComponentExists( Owner, NewName ) then
begin
I := 1;
Done := False;
repeat
Inc( I );
if not ComponentExists( AOwner, NewName + IntToStr( I ) ) then
begin
Result := NewName + IntToStr( I );
Done := True;
end;
until Done;
end
else
Result := NewName;
end; { TTTSLENDTable.GenerateNewFieldName }
function TTTSLENDTable.CreateField( const FieldName : string ): TField;
begin
{ First, try to find an existing field object. FindField is the same }
{ as FieldByName, but does not raise an exception if the field object }
{ cannot be found. }
Result := FindField( FieldName );
if Result = nil then
begin
{ If an existing field object cannot be found... }
{ Instruct the FieldDefs object to create a new field object }
Result := FieldDefs.Find( FieldName ).CreateField( Owner );
{ The new field object must be given a name so that it may appear in }
{ the Object Inspector. The Delphi default naming convention is used.}
Result.Name := GenerateNewFieldName( Owner, Name, FieldName);
end;
end; { TTTSLENDTable.CreateField }
procedure TTTSLENDTable.CreateFields;
begin
FDFLenderNum := CreateField( 'LenderNum' ) as TStringField;
FDFModCount := CreateField( 'ModCount' ) as TIntegerField;
FDFName := CreateField( 'Name' ) as TStringField;
FDFAddr1 := CreateField( 'Addr1' ) as TStringField;
FDFAddr2 := CreateField( 'Addr2' ) as TStringField;
FDFCity := CreateField( 'City' ) as TStringField;
FDFState := CreateField( 'State' ) as TStringField;
FDFZip := CreateField( 'Zip' ) as TStringField;
FDFPhone := CreateField( 'Phone' ) as TStringField;
FDFOptions := CreateField( 'Options' ) as TStringField;
FDFAdmin := CreateField( 'Admin' ) as TStringField;
FDFScreen := CreateField( 'Screen' ) as TStringField;
FDFCombHeaderID := CreateField( 'CombHeaderID' ) as TIntegerField;
FDFCombFooterID := CreateField( 'CombFooterID' ) as TIntegerField;
FDFCombHeaderText := CreateField( 'CombHeaderText' ) as TBlobField;
FDFCombFooterText := CreateField( 'CombFooterText' ) as TBlobField;
FDFCaptions := CreateField( 'Captions' ) as TBlobField;
FDFFlagCaptions := CreateField( 'FlagCaptions' ) as TStringField;
end; { TTTSLENDTable.CreateFields }
procedure TTTSLENDTable.SetActive(Value: Boolean);
begin
inherited SetActive(Value);
if Active then
CreateFields;
end; { TTTSLENDTable.SetActive }
procedure TTTSLENDTable.SetPLenderNum(const Value: String);
begin
DFLenderNum.Value := Value;
end;
function TTTSLENDTable.GetPLenderNum:String;
begin
result := DFLenderNum.Value;
end;
procedure TTTSLENDTable.SetPModCount(const Value: Integer);
begin
DFModCount.Value := Value;
end;
function TTTSLENDTable.GetPModCount:Integer;
begin
result := DFModCount.Value;
end;
procedure TTTSLENDTable.SetPName(const Value: String);
begin
DFName.Value := Value;
end;
function TTTSLENDTable.GetPName:String;
begin
result := DFName.Value;
end;
procedure TTTSLENDTable.SetPAddr1(const Value: String);
begin
DFAddr1.Value := Value;
end;
function TTTSLENDTable.GetPAddr1:String;
begin
result := DFAddr1.Value;
end;
procedure TTTSLENDTable.SetPAddr2(const Value: String);
begin
DFAddr2.Value := Value;
end;
function TTTSLENDTable.GetPAddr2:String;
begin
result := DFAddr2.Value;
end;
procedure TTTSLENDTable.SetPCity(const Value: String);
begin
DFCity.Value := Value;
end;
function TTTSLENDTable.GetPCity:String;
begin
result := DFCity.Value;
end;
procedure TTTSLENDTable.SetPState(const Value: String);
begin
DFState.Value := Value;
end;
function TTTSLENDTable.GetPState:String;
begin
result := DFState.Value;
end;
procedure TTTSLENDTable.SetPZip(const Value: String);
begin
DFZip.Value := Value;
end;
function TTTSLENDTable.GetPZip:String;
begin
result := DFZip.Value;
end;
procedure TTTSLENDTable.SetPPhone(const Value: String);
begin
DFPhone.Value := Value;
end;
function TTTSLENDTable.GetPPhone:String;
begin
result := DFPhone.Value;
end;
procedure TTTSLENDTable.SetPOptions(const Value: String);
begin
DFOptions.Value := Value;
end;
function TTTSLENDTable.GetPOptions:String;
begin
result := DFOptions.Value;
end;
procedure TTTSLENDTable.SetPAdmin(const Value: String);
begin
DFAdmin.Value := Value;
end;
function TTTSLENDTable.GetPAdmin:String;
begin
result := DFAdmin.Value;
end;
procedure TTTSLENDTable.SetPScreen(const Value: String);
begin
DFScreen.Value := Value;
end;
function TTTSLENDTable.GetPScreen:String;
begin
result := DFScreen.Value;
end;
procedure TTTSLENDTable.SetPCombHeaderID(const Value: Integer);
begin
DFCombHeaderID.Value := Value;
end;
function TTTSLENDTable.GetPCombHeaderID:Integer;
begin
result := DFCombHeaderID.Value;
end;
procedure TTTSLENDTable.SetPCombFooterID(const Value: Integer);
begin
DFCombFooterID.Value := Value;
end;
function TTTSLENDTable.GetPCombFooterID:Integer;
begin
result := DFCombFooterID.Value;
end;
procedure TTTSLENDTable.SetPFlagCaptions(const Value: String);
begin
DFFlagCaptions.Value := Value;
end;
function TTTSLENDTable.GetPFlagCaptions:String;
begin
result := DFFlagCaptions.Value;
end;
procedure TTTSLENDTable.LoadFieldDefs(AStringList: TStringList);
begin
inherited;
with AstringList do
begin
Add('LenderNum, String, 4, N');
Add('ModCount, Integer, 0, N');
Add('Name, String, 40, N');
Add('Addr1, String, 40, N');
Add('Addr2, String, 40, N');
Add('City, String, 25, N');
Add('State, String, 2, N');
Add('Zip, String, 10, N');
Add('Phone, String, 40, N');
Add('Options, String, 99, N');
Add('Admin, String, 30, N');
Add('Screen, String, 12, N');
Add('CombHeaderID, Integer, 0, N');
Add('CombFooterID, Integer, 0, N');
Add('CombHeaderText, Memo, 0, N');
Add('CombFooterText, Memo, 0, N');
Add('Captions, Memo, 0, N');
Add('FlagCaptions, String, 110, N');
end;
end;
procedure TTTSLENDTable.LoadIndexDefs(AStringList: TStringList);
begin
inherited;
with AstringList do
begin
Add('PrimaryKey, LenderNum, Y, Y, N, N');
Add('ByName, Name;LenderNum, N, N, Y, N');
end;
end;
procedure TTTSLENDTable.SetEnumIndex(Value: TEITTSLEND);
begin
case Value of
TTSLENDPrimaryKey : IndexName := '';
TTSLENDByName : IndexName := 'ByName';
end;
end;
function TTTSLENDTable.GetDataBuffer:TTTSLENDRecord;
var buf: TTTSLENDRecord;
begin
fillchar(buf, sizeof(buf), 0);
buf.PLenderNum := DFLenderNum.Value;
buf.PModCount := DFModCount.Value;
buf.PName := DFName.Value;
buf.PAddr1 := DFAddr1.Value;
buf.PAddr2 := DFAddr2.Value;
buf.PCity := DFCity.Value;
buf.PState := DFState.Value;
buf.PZip := DFZip.Value;
buf.PPhone := DFPhone.Value;
buf.POptions := DFOptions.Value;
buf.PAdmin := DFAdmin.Value;
buf.PScreen := DFScreen.Value;
buf.PCombHeaderID := DFCombHeaderID.Value;
buf.PCombFooterID := DFCombFooterID.Value;
buf.PFlagCaptions := DFFlagCaptions.Value;
result := buf;
end;
procedure TTTSLENDTable.StoreDataBuffer(ABuffer:TTTSLENDRecord);
begin
DFLenderNum.Value := ABuffer.PLenderNum;
DFModCount.Value := ABuffer.PModCount;
DFName.Value := ABuffer.PName;
DFAddr1.Value := ABuffer.PAddr1;
DFAddr2.Value := ABuffer.PAddr2;
DFCity.Value := ABuffer.PCity;
DFState.Value := ABuffer.PState;
DFZip.Value := ABuffer.PZip;
DFPhone.Value := ABuffer.PPhone;
DFOptions.Value := ABuffer.POptions;
DFAdmin.Value := ABuffer.PAdmin;
DFScreen.Value := ABuffer.PScreen;
DFCombHeaderID.Value := ABuffer.PCombHeaderID;
DFCombFooterID.Value := ABuffer.PCombFooterID;
DFFlagCaptions.Value := ABuffer.PFlagCaptions;
end;
function TTTSLENDTable.GetEnumIndex: TEITTSLEND;
var iname : string;
begin
result := TTSLENDPrimaryKey;
iname := uppercase(indexname);
if iname = '' then result := TTSLENDPrimaryKey;
if iname = 'BYNAME' then result := TTSLENDByName;
end;
(********************************************)
(************ Register Component ************)
(********************************************)
procedure Register;
begin
RegisterComponents( 'TTS Tables', [ TTTSLENDTable, TTTSLENDBuffer ] );
end; { Register }
function TTTSLENDBuffer.FieldNameToIndex(s:string):integer;
const flist:array[1..15] of string = ('LENDERNUM','MODCOUNT','NAME','ADDR1','ADDR2','CITY'
,'STATE','ZIP','PHONE','OPTIONS','ADMIN'
,'SCREEN','COMBHEADERID','COMBFOOTERID','FLAGCAPTIONS' );
var x : integer;
begin
s := uppercase(s);
x := 1;
while (x <= 15) and (flist[x] <> s) do inc(x);
if x <= 15 then result := x else result := 0;
end;
function TTTSLENDBuffer.FieldType(index:integer):TFieldType;
begin
result := ftUnknown;
case index of
1 : result := ftString;
2 : result := ftInteger;
3 : result := ftString;
4 : result := ftString;
5 : result := ftString;
6 : result := ftString;
7 : result := ftString;
8 : result := ftString;
9 : result := ftString;
10 : result := ftString;
11 : result := ftString;
12 : result := ftString;
13 : result := ftInteger;
14 : result := ftInteger;
15 : result := ftString;
end;
end;
function TTTSLENDBuffer.PtrIndex(index:integer):Pointer;
begin
result := nil;
case index of
1 : result := @Data.PLenderNum;
2 : result := @Data.PModCount;
3 : result := @Data.PName;
4 : result := @Data.PAddr1;
5 : result := @Data.PAddr2;
6 : result := @Data.PCity;
7 : result := @Data.PState;
8 : result := @Data.PZip;
9 : result := @Data.PPhone;
10 : result := @Data.POptions;
11 : result := @Data.PAdmin;
12 : result := @Data.PScreen;
13 : result := @Data.PCombHeaderID;
14 : result := @Data.PCombFooterID;
15 : result := @Data.PFlagCaptions;
end;
end;
end.
|
unit D2009Win2kFix;
{
Inno Setup
Copyright (C) 1997-2010 Jordan Russell
Portions by Martijn Laan
For conditions of distribution and use, see LICENSE.TXT.
When Windows 2000 with SP<4 is detected, this unit reverts the change in
Delphi 2009 Update 3 that causes VCL apps (even new, empty projects) to
crash on startup when run on Windows 2000 with no SP/SP1/SP2/sometimes SP3.
This should be at the top of the .dpr's "uses" clause to ensure it runs
before any VCL code.
$jrsoftware: issrc/Projects/D2009Win2kFix.pas,v 1.2 2010/03/05 08:42:04 mlaan Exp $
}
interface
implementation
{$IFDEF VER200}
{$DEFINE Delphi2009Or2010}
{$ENDIF}
{$IFDEF VER210}
{$DEFINE Delphi2009Or2010}
{$ENDIF}
{$IFDEF Delphi2009Or2010} { Only Delphi 2009/2010 }
uses
Windows, SysUtils;
{
Details:
In Delphi 2009 Update 3 (or possibly one of the previous updates),
TUTF8Encoding.Create in SysUtils was changed to set the
MB_ERR_INVALID_CHARS flag:
original: inherited Create(CP_UTF8);
with Update 3: inherited Create(CP_UTF8, MB_ERR_INVALID_CHARS, 0);
It appears that when used with CP_UTF8, the MB_ERR_INVALID_CHARS flag is
only supported beginning with Windows 2000 SP4 and Windows XP. On Windows
2000 with no SP, MultiByteToWideChar() fails with ERROR_INVALID_FLAGS.
In Delphi 2010 Update 1 this change is still present.
This code changes TEncoding.UTF8's private FMBToWCharFlags field from
MB_ERR_INVALID_CHARS back to 0 when Windows 2000 (5.0) with SP<4 is
detected.
Note: This won't fix any other instances of TUTF8Encoding, but there
shouldn't be more than just the one. (Inside the Delphi RTL/VCL,
TEncoding.GetUTF8 is the only place where TUTF8Encoding.Create is called.)
}
function NeedWin2kFix: Boolean;
var
Info: TOSVersionInfoEx;
begin
Result := False;
Info.dwOSVersionInfoSize := SizeOf(Info);
if GetVersionEx(Info) then
if (Info.dwMajorVersion = 5) and (Info.dwMinorVersion = 0) and
(Info.wServicePackMajor < 4) then
Result := True;
end;
procedure ApplyWin2kFix;
type
PLongWordArray = ^TLongWordArray;
TLongWordArray = array[0..6] of LongWord; { 28 bytes }
var
U: SysUtils.TEncoding;
begin
U := SysUtils.TEncoding.UTF8;
if (U.ClassType = SysUtils.TUTF8Encoding) and
(U.InstanceSize = 28) and
(U is SysUtils.TMBCSEncoding) and
(SysUtils.TMBCSEncoding.InstanceSize = 28) then begin
if (PLongWordArray(U)[3] = 65001) and { verify that FCodePage = CP_UTF8 }
(PLongWordArray(U)[4] = 8) and { verify that FMBToWCharFlags = MB_ERR_INVALID_CHARS }
(PLongWordArray(U)[5] = 0) then { verify that FWCharToMBFlags = 0 }
PLongWordArray(U)[4] := 0; { change FMBToWCharFlags to 0 }
end;
end;
initialization
if NeedWin2kFix then
ApplyWin2kFix;
{$ENDIF}
end.
|
unit vg_colors;
{$I vg_define.inc}
interface
uses
{$IFNDEF NOVCL}
{$IFDEF UCL} UControls, {$ELSE} Controls, {$ENDIF}
{$ENDIF}
Classes, Variants, SysUtils, vg_objects, vg_scene, vg_controls, vg_textbox,
vgCustomCanvas,
vgBitmap
;
const
colorPickSize = 10;
type
TvgBitmapTrackBar = class(TvgTrackBar)
private
FBitmap: TvgBitmap;
FBackground: TvgShape;
protected
procedure ApplyStyle; override;
procedure FreeStyle; override;
procedure Realign; override;
procedure UpdateBitmap;
procedure FillBitmap; virtual;
public
constructor Create(AOwner: TComponent); override;
procedure Cleanup; override;
published
end;
TvgHueTrackBar = class(TvgBitmapTrackBar)
private
protected
procedure FillBitmap; override;
public
constructor Create(AOwner: TComponent); override;
published
end;
TvgAlphaTrackBar = class(TvgBitmapTrackBar)
private
protected
procedure FillBitmap; override;
public
constructor Create(AOwner: TComponent); override;
published
end;
TvgBWTrackBar = class(TvgBitmapTrackBar)
private
protected
procedure FillBitmap; override;
public
constructor Create(AOwner: TComponent); override;
published
end;
TvgColorBox = class(TvgControl)
private
FColor: TvgColor;
procedure SetColor(const Value: TvgColor);
protected
public
constructor Create(AOwner: TComponent); override;
procedure Paint; override;
property Color: TvgColor read FColor write SetColor;
published
end;
TvgColorQuad = class(TvgControl)
private
FColorBox: TvgColorBox;
FColorBitmap: TvgBitmap;
FHue: single;
FSat: single;
FLum: single;
FOnChange: TNotifyEvent;
FAlpha: single;
procedure SetHue(const Value: single);
procedure SetLum(const Value: single);
procedure SetSat(const Value: single);
procedure SetAlpha(const Value: single);
procedure SetColorBox(const Value: TvgColorBox);
protected
procedure MouseMove(Shift: TShiftState; X, Y, Dx, Dy: single); override;
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: single); override;
function GetAbsoluteRect: TvgRect; override;
function pointInObject(X, Y: single): boolean; override;
procedure Notification(AComponent: TComponent;
Operation: TOperation); override;
public
constructor Create(AOwner: TComponent); override;
procedure Cleanup; override;
procedure Paint; override;
published
property Hue: single read FHue write SetHue;
property Lum: single read FLum write SetLum;
property Sat: single read FSat write SetSat;
property Alpha: single read FAlpha write SetAlpha;
property ColorBox: TvgColorBox read FColorBox write SetColorBox;
property OnChange: TNotifyEvent read FOnChange write FOnChange;
end;
TvgColorPicker = class(TvgControl)
private
FHueBitmap: TvgBitmap;
FHue: single;
FColorQuad: TvgColorQuad;
procedure SetHue(const Value: single);
function GetColor: TvgColor;
procedure SetColor(const Value: TvgColor);
protected
procedure MouseMove(Shift: TShiftState; X, Y, Dx, Dy: single); override;
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: single); override;
function GetAbsoluteRect: TvgRect; override;
function pointInObject(X, Y: single): boolean; override;
procedure Notification(AComponent: TComponent;
Operation: TOperation); override;
public
constructor Create(AOwner: TComponent); override;
procedure Cleanup; override;
procedure Paint; override;
property Color: TvgColor read GetColor write SetColor;
published
property Hue: single read FHue write SetHue;
property ColorQuad: TvgColorQuad read FColorQuad write FColorQuad;
end;
TvgGradientEdit = class(TvgControl)
private
FBitmap: TvgBitmap;
FGradient: TvgGradient;
FCurrentPoint: integer;
FCurrentPointInvisible: boolean;
FMoving: boolean;
FOnChange: TNotifyEvent;
FOnSelectPoint: TNotifyEvent;
FColorPicker: TvgColorPicker;
procedure SetGradient(const Value: TvgGradient);
function GetPointRect(const Point: integer): TvgRect;
procedure DoChanged(Sender: TObject);
procedure SetCurrentPoint(const Value: integer);
procedure SetColorPicker(const Value: TvgColorPicker);
protected
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: single); override;
procedure MouseMove(Shift: TShiftState; X, Y, Dx, Dy: single); override;
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: single); override;
procedure Notification(AComponent: TComponent;
Operation: TOperation); override;
public
constructor Create(AOwner: TComponent); override;
procedure Cleanup; override;
procedure Paint; override;
procedure UpdateGradient;
property Gradient: TvgGradient read FGradient write SetGradient;
property CurrentPoint: integer read FCurrentPoint write SetCurrentPoint;
published
property OnChange: TNotifyEvent read FOnChange write FOnChange;
property OnSelectPoint: TNotifyEvent read FOnSelectPoint write FOnSelectPoint;
property ColorPicker: TvgColorPicker read FColorPicker write SetColorPicker;
end;
TvgColorPanel = class(TvgControl)
private
FOnChange: TNotifyEvent;
FColorQuad: TvgColorQuad;
FAlphaTrack: TvgAlphaTrackBar;
FHueTrack: TvgHueTrackBar;
FColorBox: TvgColorBox;
FUseAlpha: boolean;
function GetColor: string;
procedure SetColor(const Value: string);
procedure SetColorBox(const Value: TvgColorBox);
procedure SetUseAlpha(const Value: boolean);
protected
procedure DoAlphaChange(Sender: TObject);
procedure DoHueChange(Sender: TObject);
procedure DoQuadChange(Sender: TObject);
procedure Notification(AComponent: TComponent;
Operation: TOperation); override;
procedure Loaded; override;
public
constructor Create(AOwner: TComponent); override;
procedure Cleanup; override;
published
property OnChange: TNotifyEvent read FOnChange write FOnChange;
property Color: string read GetColor write SetColor;
property ColorBox: TvgColorBox read FColorBox write SetColorBox;
property UseAlpha: boolean read FUseAlpha write SetUseAlpha default true;
end;
TvgComboColorBox = class(TvgControl)
private
FPopup: TvgPopup;
FColorPanel: TvgColorPanel;
FColorBox: TvgColorBox;
FColorText: TvgTextBox;
FPlacement: TvgPlacement;
FOnChange: TNotifyEvent;
function GetValue: string;
procedure SetValue(const Value: string);
function GetUseAlpha: boolean;
procedure SetUseAlpha(const Value: boolean);
protected
procedure ApplyStyle; override;
procedure DoContentPaint(Sender: TObject; Canvas: TvgCustomCanvas; const ARect: TvgRect);
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: single); override;
{$IfNDef Nemesis}
procedure ChangeParent; override;
{$EndIf Nemesis}
procedure DoColorChange(Sender: TObject); virtual;
procedure DoTextChange(Sender: TObject); virtual;
function GetData: Variant; override;
procedure SetData(const Value: Variant); override;
public
constructor Create(AOwner: TComponent); override;
procedure Cleanup; override;
procedure DropDown;
published
property CanFocused default true;
property DisableFocusEffect;
property TabOrder;
property Color: string read GetValue write SetValue;
property UseAlpha: boolean read GetUseAlpha write SetUseAlpha default true;
property OnChange: TNotifyEvent read FOnChange write FOnChange;
end;
TvgHudHueTrackBar = class(TvgHueTrackBar)
private
protected
public
constructor Create(AOwner: TComponent); override;
published
end;
TvgHudAlphaTrackBar = class(TvgAlphaTrackBar)
private
protected
public
constructor Create(AOwner: TComponent); override;
published
end;
TvgHudBWTrackBar = class(TvgBitmapTrackBar)
private
protected
public
constructor Create(AOwner: TComponent); override;
published
end;
TvgHudComboColorBox = class(TvgComboColorBox)
private
protected
public
constructor Create(AOwner: TComponent); override;
published
end;
implementation {===============================================================}
uses
vgTypes
;
{ TvgBitmapTrackBar }
constructor TvgBitmapTrackBar.Create(AOwner: TComponent);
begin
inherited;
FResource := 'trackbarstyle';
end;
procedure TvgBitmapTrackBar.Cleanup;
begin
if FBitmap <> nil then
FreeAndNil(FBitmap);
inherited;
end;
procedure TvgBitmapTrackBar.ApplyStyle;
var
T: TvgObject;
begin
inherited;
T := FindResource('background');
if (T <> nil) and (T is TvgShape) then
begin
FBackground := TvgShape(T);
UpdateBitmap;
end;
end;
procedure TvgBitmapTrackBar.FreeStyle;
begin
FBackground := nil;
inherited;
end;
procedure TvgBitmapTrackBar.Realign;
begin
inherited;
UpdateBitmap;
end;
procedure TvgBitmapTrackBar.UpdateBitmap;
begin
if FBackground = nil then Exit;
if FBitmap <> nil then
if (FBitmap.Width <> Trunc(FBackground.Width)) or (FBitmap.Height <> Trunc(FBackground.Height)) then
begin
FreeAndNil(FBitmap);
end;
if FBitmap = nil then
begin
FBitmap := TvgBitmap.Create(Trunc(FBackground.Width), Trunc(FBackground.Height));
FillBitmap;
end;
FBackground.Fill.Style := vgBrushBitmap;
FBackground.Fill.Bitmap.Bitmap := FBitmap;
Repaint;
end;
procedure TvgBitmapTrackBar.FillBitmap;
begin
end;
{ TvgHueTrackBar }
constructor TvgHueTrackBar.Create(AOwner: TComponent);
begin
inherited;
Max := 1;
Value := 0.5;
end;
procedure TvgHueTrackBar.FillBitmap;
var
i, j: integer;
begin
for j := 0 to FBitmap.Height - 1 do
begin
for i := 0 to FBitmap.Width - 1 do
begin
if Orientation = vgHorizontal then
FBitmap.Scanline[j][i] := vgCorrectColor(vgHSLtoRGB(i / FBitmap.Width, 0.9, 0.5))
else
FBitmap.Scanline[j][i] := vgCorrectColor(vgHSLtoRGB(j / FBitmap.Height, 0.9, 0.5));
end;
end;
end;
{ TvgAlphaTrackBar }
constructor TvgAlphaTrackBar.Create(AOwner: TComponent);
begin
inherited;
Max := 1;
Value := 1;
end;
procedure TvgAlphaTrackBar.FillBitmap;
var
i, j: integer;
begin
for j := 0 to FBitmap.Height - 1 do
begin
for i := 0 to FBitmap.Width - 1 do
begin
if odd(i div 3) and not odd(j div 3) then
FBitmap.Scanline[j][i] := vgCorrectColor($FFA0A0A0)
else
if not odd(i div 3) and odd(j div 3) then
FBitmap.Scanline[j][i] := vgCorrectColor($FFA0A0A0)
else
FBitmap.Scanline[j][i] := vgCorrectColor($FFFFFFFF)
end;
end;
if TvgCanvas(FBitmap.Canvas).BeginScene then
begin
TvgCanvas(FBitmap.Canvas).Fill.Style := vgBrushGradient;
TvgCanvas(FBitmap.Canvas).Fill.Gradient.Points[0].Color := '$00FFFFFF';
TvgCanvas(FBitmap.Canvas).Fill.Gradient.Points[1].Color := '$FFFFFFFF';
TvgCanvas(FBitmap.Canvas).Fill.Gradient.StopPosition.Point := vgPoint(1, 0);
TvgCanvas(FBitmap.Canvas).FillRect(vgRect(0, 0, FBitmap.Width, FBitmap.Height), 0, 0, [], 1);
TvgCanvas(FBitmap.Canvas).EndScene;
end;
end;
{ TvgBWTrackBar }
constructor TvgBWTrackBar.Create(AOwner: TComponent);
begin
inherited;
Max := 1;
Value := 0.5;
end;
procedure TvgBWTrackBar.FillBitmap;
var
i, j: integer;
a: byte;
begin
for j := 0 to FBitmap.Height - 1 do
begin
for i := 0 to FBitmap.Width - 1 do
begin
if Orientation = vgHorizontal then
a := round((i / FBitmap.Width) * $FF)
else
a := round((j / FBitmap.Height) * $FF);
FBitmap.Scanline[j][i] := vgCorrectColor(vgColor(a, a, a));
end;
end;
end;
{ TvgColorBox }
constructor TvgColorBox.Create(AOwner: TComponent);
begin
inherited;
end;
procedure TvgColorBox.Paint;
var
i, j: integer;
SaveIndex: integer;
begin
SaveIndex := TvgCanvas(Canvas).SaveCanvas;
TvgCanvas(Canvas).IntersectClipRect(LocalRect);
TvgCanvas(Canvas).Stroke.Style := vgBrushNone;
TvgCanvas(Canvas).Fill.Style := vgBrushSolid;
TvgCanvas(Canvas).Fill.SolidColor := $FFFFFFFF;
TvgCanvas(Canvas).FillRect(LocalRect, 0, 0, AllCorners, AbsoluteOpacity);
TvgCanvas(Canvas).Fill.SolidColor := $FFD3D3D3;
for i := 0 to Trunc(Width / 5) + 1 do
for j := 0 to Trunc(Height / 5) + 1 do
begin
if Odd(i + j) then
begin
TvgCanvas(Canvas).FillRect(vgRect(i * 5, j * 5, (i + 1) * 5, (j + 1) * 5), 0, 0, AllCorners, AbsoluteOpacity);
end;
end;
TvgCanvas(Canvas).RestoreCanvas(SaveIndex);
TvgCanvas(Canvas).Fill.Style := vgBrushSolid;
TvgCanvas(Canvas).Fill.SolidColor := FColor;
TvgCanvas(Canvas).FillRect(LocalRect, 0, 0, AllCorners, AbsoluteOpacity);
end;
procedure TvgColorBox.SetColor(const Value: TvgColor);
begin
if FColor <> Value then
begin
FColor := Value;
Repaint;
end;
end;
{ TvgColorQuad }
constructor TvgColorQuad.Create(AOwner: TComponent);
begin
inherited;
FAlpha := 1;
AutoCapture := true;
end;
procedure TvgColorQuad.Cleanup;
begin
if (FColorBitmap <> nil) then
FreeAndNil(FColorBitmap);
inherited;
end;
function TvgColorQuad.GetAbsoluteRect: TvgRect;
begin
Result := inherited GetAbsoluteRect;
vgInflateRect(Result, colorPickSize + 1, colorPickSize + 1);
end;
function TvgColorQuad.pointInObject(X, Y: single): boolean;
var
P: TvgPoint;
begin
Result := false;
P := AbsoluteToLocal(vgPoint(X, Y));
if (P.X > -colorPickSize / 2) and (P.X < Width + colorPickSize / 2) and
(P.Y > -colorPickSize / 2) and (P.Y < Height + colorPickSize / 2) then
begin
Result := true;
end;
end;
procedure TvgColorQuad.MouseMove(Shift: TShiftState; X, Y, Dx, Dy: single);
begin
inherited;
if FPressed then
begin
if Height <> 0 then
Lum := 1 - ((Y) / (Height));
if Width <> 0 then
Sat := ((X) / (Width));
end;
end;
procedure TvgColorQuad.MouseUp(Button: TMouseButton; Shift: TShiftState; X,
Y: single);
begin
if FPressed then
MouseMove([ssLeft], X, Y, 0, 0);
inherited;
end;
procedure TvgColorQuad.Notification(AComponent: TComponent;
Operation: TOperation);
begin
inherited;
if (Operation = opRemove) and (AComponent = FColorBox) then
ColorBox := nil;
end;
procedure TvgColorQuad.Paint;
var
i, j: integer;
R: TvgRect;
begin
if FColorBitmap = nil then
begin
FColorBitmap := TvgBitmap.Create(Trunc(Width), Trunc(Height));
if FColorBitmap <> nil then
begin
for i := 0 to FColorBitmap.Width - 1 do
begin
for j := 0 to FColorBitmap.Height - 1 do
begin
FColorBitmap.Scanline[j][i] := vgCorrectColor(vgHSLtoRGB(FHue, i / FColorBitmap.Width, (1 - (j / FColorBitmap.Height))));
{$ifdef FPC_BIG_ENDIAN}
ReverseBytes(@FColorBitmap.Scanline[j][i], 4);
{$endif}
end;
end;
end;
end;
if FColorBitmap <> nil then
TvgCanvas(Canvas).DrawBitmap(FColorBitmap, vgRect(0, 0, FColorBitmap.Width, FColorBitmap.Height),
vgRect(0, 0, Width, Height), AbsoluteOpacity);
{ current }
R := vgRect(FSat * (Width), (1 - FLum) * (Height),
FSat * (Width), (1 - FLum) * (Height));
vgInflateRect(R, colorPickSize / 2, colorPickSize / 2);
TvgCanvas(Canvas).Stroke.Style := vgBrushSolid;
TvgCanvas(Canvas).StrokeThickness := 1;
TvgCanvas(Canvas).Stroke.SolidColor := $FF000000;
TvgCanvas(Canvas).DrawEllipse(R, AbsoluteOpacity);
vgInflateRect(R, -1, -1);
TvgCanvas(Canvas).Stroke.SolidColor := $FFFFFFFF;
TvgCanvas(Canvas).DrawEllipse(R, AbsoluteOpacity);
vgInflateRect(R, -1, -1);
TvgCanvas(Canvas).Fill.Style := vgBrushSolid;
TvgCanvas(Canvas).Fill.SolidColor := vgHSLtoRGB(Hue, sat, Lum);
TvgCanvas(Canvas).FillEllipse(R, AbsoluteOpacity);
end;
procedure TvgColorQuad.SetAlpha(const Value: single);
begin
if FAlpha <> Value then
begin
FAlpha := Value;
if FAlpha < 0 then FAlpha := 0;
if FAlpha > 1 then FAlpha := 1;
if FColorBox <> nil then
FColorBox.Color := vgHSLtoRGB(Hue, Sat, Lum) and $FFFFFF or (Round(Alpha * $FF) shl 24);
if Assigned(FOnChange) then
FOnChange(Self);
end;
end;
procedure TvgColorQuad.SetHue(const Value: single);
begin
if FHue <> Value then
begin
FHue := Value;
if FHue < 0 then FHue := 0;
if FHue > 1 then FHue := 1;
if FColorBitmap <> nil then
FreeAndNil(FColorBitmap);
if FColorBox <> nil then
FColorBox.Color := vgHSLtoRGB(Hue, Sat, Lum) and $FFFFFF or (Round(Alpha * $FF) shl 24);
if Assigned(FOnChange) then
FOnChange(Self);
Repaint;
end;
end;
procedure TvgColorQuad.SetLum(const Value: single);
begin
if FLum <> Value then
begin
FLum := Value;
if FLum < 0 then FLum := 0;
if FLum > 1 then FLum := 1;
if FColorBox <> nil then
FColorBox.Color := vgHSLtoRGB(Hue, Sat, Lum) and $FFFFFF or (Round(Alpha * $FF) shl 24);
if Assigned(FOnChange) then
FOnChange(Self);
Repaint;
end;
end;
procedure TvgColorQuad.SetSat(const Value: single);
begin
if FSat <> Value then
begin
FSat := Value;
if FSat < 0 then FSat := 0;
if FSat > 1 then FSat := 1;
if FColorBox <> nil then
FColorBox.Color := vgHSLtoRGB(Hue, Sat, Lum) and $FFFFFF or (Round(Alpha * $FF) shl 24);
if Assigned(FOnChange) then
FOnChange(Self);
Repaint;
end;
end;
procedure TvgColorQuad.SetColorBox(const Value: TvgColorBox);
begin
if FColorBox <> Value then
begin
FColorBox := Value;
if FColorBox <> nil then
FColorBox.Color := vgHSLtoRGB(Hue, Sat, Lum) and $FFFFFF or (Round(Alpha * $FF) shl 24);
end;
end;
{ TvgColorPicker ==============================================================}
constructor TvgColorPicker.Create(AOwner: TComponent);
begin
inherited;
AutoCapture := true;
end;
procedure TvgColorPicker.Cleanup;
begin
if (FHueBitmap <> nil) then
FreeAndNil(FHueBitmap);
inherited;
end;
procedure TvgColorPicker.Notification(AComponent: TComponent;
Operation: TOperation);
begin
inherited;
if (Operation = opRemove) and (AComponent = FColorQuad) then
ColorQuad := nil;
end;
function TvgColorPicker.GetAbsoluteRect: TvgRect;
begin
Result := inherited GetAbsoluteRect;
vgInflateRect(Result, 0, colorPickSize / 2);
end;
function TvgColorPicker.pointInObject(X, Y: single): boolean;
var
P: TvgPoint;
begin
Result := false;
P := AbsoluteToLocal(vgPoint(X, Y));
if (P.X > 0) and (P.X < Width) and
(P.Y > -colorPickSize / 2) and (P.Y < Height + colorPickSize / 2) then
begin
Result := true;
end;
end;
procedure TvgColorPicker.MouseMove(Shift: TShiftState; X, Y, Dx,
Dy: single);
begin
inherited;
if FPressed then
begin
if Height <> 0 then
Hue := ((Y) / (Height));
end;
end;
procedure TvgColorPicker.MouseUp(Button: TMouseButton; Shift: TShiftState;
X, Y: single);
begin
if FPressed then
MouseMove([ssLeft], X, Y, 0, 0);
inherited;
end;
procedure TvgColorPicker.Paint;
var
i, j: integer;
R: TvgRect;
begin
if FHueBitmap = nil then
begin
FHueBitmap := TvgBitmap.Create(Trunc(Width), Trunc(Height));
if FHueBitmap <> nil then
begin
for j := 0 to FHueBitmap.Height - 1 do
begin
for i := 0 to FHueBitmap.Width - 1 do
begin
FHueBitmap.Scanline[j][i] := vgCorrectColor(vgHSLtoRGB(j / FHueBitmap.Height, 0.9, 0.5));
{$ifdef FPC_BIG_ENDIAN}
ReverseBytes(@FHueBitmap.Scanline[j][i], 4);
{$endif}
end;
end;
end;
end;
if FHueBitmap <> nil then
TvgCanvas(Canvas).DrawBitmap(FHueBitmap, vgRect(0, 0, FHueBitmap.Width, FHueBitmap.Height),
vgRect(0, 0, Width, Height), AbsoluteOpacity);
{ hue pos }
R := vgRect(Width / 2, FHue * (Height),
Width / 2, FHue * (Height));
vgInflateRect(R, colorPickSize / 2, colorPickSize / 2);
// vgOffsetRect(R, 01, StrokeThickness);
TvgCanvas(Canvas).Stroke.Style := vgBrushSolid;
TvgCanvas(Canvas).StrokeThickness := 1;
TvgCanvas(Canvas).Stroke.SolidColor := $FF000000;
TvgCanvas(Canvas).DrawEllipse(R, AbsoluteOpacity);
vgInflateRect(R, -1, -1);
TvgCanvas(Canvas).Stroke.SolidColor := $FFFFFFFF;
TvgCanvas(Canvas).DrawEllipse(R, AbsoluteOpacity);
vgInflateRect(R, -1, -1);
TvgCanvas(Canvas).Fill.Style := vgBrushSolid;
TvgCanvas(Canvas).Fill.SolidColor := vgHSLtoRGB(Hue, 0.9, 0.5);
TvgCanvas(Canvas).FillEllipse(R, AbsoluteOpacity);
end;
function TvgColorPicker.GetColor: TvgColor;
begin
Result := vgHSLToRGB(Hue,1,0.5)
end;
procedure TvgColorPicker.SetColor(const Value: TvgColor);
var
H, S, L: single;
SaveChange: TNotifyEvent;
begin
vgRGBtoHSL(Value, H, S, L);
Hue := H;
if FColorQuad <> nil then
begin
FColorQuad.Alpha := TvgColorRec(Value).A / $FF;
FColorQuad.Hue := H;
FColorQuad.Sat := S;
FColorQuad.Lum := L;
end;
end;
procedure TvgColorPicker.SetHue(const Value: single);
begin
if FHue <> Value then
begin
FHue := Value;
if FHue < 0 then FHue := 0;
if FHue > 1 then FHue := 1;
if FColorQuad <> nil then
FColorQuad.Hue := FHue;
Repaint;
end;
end;
{ TvgGradientEdit ==============================================================}
constructor TvgGradientEdit.Create(AOwner: TComponent);
begin
inherited;
FGradient := TvgGradient.Create;
FGradient.OnChanged := DoChanged;
Width := 200;
Height := 20;
AutoCapture := true;
end;
procedure TvgGradientEdit.Cleanup;
begin
if FBitmap <> nil then
FreeAndNil(FBitmap);
FreeAndNil(FGradient);
inherited;
end;
function TvgGradientEdit.GetPointRect(const Point: integer): TvgRect;
begin
if (Point >= 0) and (Point < FGradient.Points.Count) then
with FGradient do
begin
Result := vgRect(0 + colorPickSize + (Points[Point].Offset * (Width - ((0 + colorPickSize) * 2))), Height - 0 - colorPickSize,
0 + colorPickSize + (Points[Point].Offset * (Width - ((0 + colorPickSize) * 2))), Height - 0);
vgInflateRect(Result, colorPickSize / 2, 0);
end
else
Result := vgRect(0, 0, 0, 0);
end;
procedure TvgGradientEdit.MouseDown(Button: TMouseButton;
Shift: TShiftState; X, Y: single);
var
NewOffset: single;
NewColor: TvgColor;
i: integer;
begin
inherited;
FMoving := false;
if Button = mbLeft then
begin
{ select point }
for i := 0 to FGradient.Points.Count - 1 do
if vgPtInRect(vgPoint(X, Y), GetPointRect(i)) then
begin
CurrentPoint := i;
if Assigned(OnSelectPoint) then
OnSelectPoint(Self);
FMoving := true;
Repaint;
Exit;
end;
{ add new point }
if (Y > 0) and (Y < Height - 0 - colorPickSize) then
begin
NewOffset := ((X - 0 - colorPickSize) / (Width - ((0 + colorPickSize)* 2)));
if NewOffset < 0 then NewOffset := 0;
if NewOffset > 1 then NewOffset := 1;
NewColor := FGradient.InterpolateColor(NewOffset);
for i := 1 to FGradient.Points.Count - 1 do
if NewOffset < FGradient.Points[i].Offset then
with TvgGradientPoint(FGradient.Points.Add) do
begin
Index := i;
CurrentPoint := Index;
IntColor := NewColor;
Offset := NewOffset;
Repaint;
DoChanged(Self);
Break;
end;
end;
end;
end;
procedure TvgGradientEdit.MouseMove(Shift: TShiftState; X, Y, Dx,
Dy: single);
begin
inherited;
if ssLeft in Shift then
begin
if FMoving then
begin
FCurrentPointInvisible := ((Y < -10) or (Y > Height + 10)) and (FGradient.Points.Count > 1) and
(CurrentPoint <> 0) and (CurrentPoint <> FGradient.Points.Count - 1);
{ move }
FGradient.Points[CurrentPoint].Offset := ((X - 0 - colorPickSize) / (Width - ((0 + colorPickSize) * 2)));
if FGradient.Points[CurrentPoint].Offset < 0 then
FGradient.Points[CurrentPoint].Offset := 0;
if FGradient.Points[CurrentPoint].Offset > 1 then
FGradient.Points[CurrentPoint].Offset := 1;
{ move right }
if CurrentPoint < FGradient.Points.Count - 1 then
if FGradient.Points[CurrentPoint].Offset > FGradient.Points[CurrentPoint + 1].Offset then
begin
FGradient.Points[CurrentPoint].Index := FGradient.Points[CurrentPoint].Index + 1;
CurrentPoint := CurrentPoint + 1;
end;
{ move left }
if CurrentPoint > 0 then
if FGradient.Points[CurrentPoint].Offset < FGradient.Points[CurrentPoint - 1].Offset then
begin
FGradient.Points[CurrentPoint].Index := FGradient.Points[CurrentPoint].Index - 1;
CurrentPoint := CurrentPoint - 1;
end;
Repaint;
DoChanged(Self);
end;
end;
end;
procedure TvgGradientEdit.MouseUp(Button: TMouseButton; Shift: TShiftState;
X, Y: single);
begin
inherited;
FCurrentPointInvisible := false;
if FMoving then
begin
{ delete }
if (Y > Height + 10) and (FGradient.Points.Count > 1) then
begin
FGradient.Points.Delete(CurrentPoint);
CurrentPoint := CurrentPoint - 1;
if CurrentPoint < 0 then CurrentPoint := 0;
Repaint;
DoChanged(Self);
FMoving := false;
Exit;
end;
end;
FMoving := false;
end;
procedure TvgGradientEdit.Paint;
var
i, j: integer;
R: TvgRect;
SaveIndex: integer;
begin
// TvgCanvas(Canvas).DrawRect(vgRect(0, 0, Width, Height));
if FBitmap = nil then
begin
FBitmap := TvgBitmap.Create(Trunc(Width - (0 * 2)), Trunc(Height - (0 * 2) - colorPickSize));
end;
if FBitmap <> nil then
begin
for j := 0 to FBitmap.Height - 1 do
begin
for i := 0 to FBitmap.Width - 1 do
begin
FBitmap.Scanline[j][i] := vgCorrectColor(FGradient.InterpolateColor(i / FBitmap.Width));
{$ifdef FPC_BIG_ENDIAN}
ReverseBytes(@FBitmap.Scanline[j][i], 4);
{$endif}
end;
end;
end;
{ draw back }
R := vgRect(0 + colorPickSize, 0, Width - 0 - colorPickSize, Height - 0 - colorPickSize);
SaveIndex := TvgCanvas(Canvas).SaveCanvas;
TvgCanvas(Canvas).IntersectClipRect(R);
TvgCanvas(Canvas).Stroke.Style := vgBrushNone;
TvgCanvas(Canvas).Fill.Style := vgBrushSolid;
TvgCanvas(Canvas).Fill.SolidColor := $FFFFFFFF;
TvgCanvas(Canvas).FillRect(R, 0, 0, AllCorners, AbsoluteOpacity);
TvgCanvas(Canvas).Fill.SolidColor := $FFD3D3D3;
for i := 0 to Trunc(Width / 10) + 1 do
for j := 0 to Trunc(Height / 10) + 1 do
begin
if Odd(i + j) then
begin
TvgCanvas(Canvas).FillRect(vgRect(i * 10, j * 10, (i + 1) * 10, (j + 1) * 10), 0, 0, AllCorners, AbsoluteOpacity);
end;
end;
TvgCanvas(Canvas).RestoreCanvas(SaveIndex);
{ draw gradient }
TvgCanvas(Canvas).Stroke.Style := vgBrushSolid;
TvgCanvas(Canvas).StrokeThickness := 0;
if FBitmap <> nil then
begin
TvgCanvas(Canvas).DrawBitmap(FBitmap, vgRect(0, 0, FBitmap.Width, FBitmap.Height),
vgRect(0 + colorPickSize, 0, Width - 0 - colorPickSize, Height - 0 - colorPickSize), AbsoluteOpacity);
end;
{ points }
for i := 0 to FGradient.Points.Count - 1 do
begin
if FCurrentPointInvisible and (i = CurrentPoint) then Continue;
R := GetPointRect(i);
vgInflateRect(R, -1, -1);
TvgCanvas(Canvas).Stroke.SolidColor := $FF757575;
TvgCanvas(Canvas).Fill.SolidColor := FGradient.Points[i].IntColor;
TvgCanvas(Canvas).FillEllipse(R, AbsoluteOpacity);
TvgCanvas(Canvas).DrawEllipse(R, AbsoluteOpacity);
{ color }
if CurrentPoint = i then
begin
vgInflateRect(R, 1, 1);
TvgCanvas(Canvas).Stroke.SolidColor := $FF000000;
TvgCanvas(Canvas).Stroke.SolidColor := $FFFFFFFF;
TvgCanvas(Canvas).DrawEllipse(R, AbsoluteOpacity);
end;
end;
end;
procedure TvgGradientEdit.SetGradient(const Value: TvgGradient);
begin
FGradient.Assign(Value);
end;
procedure TvgGradientEdit.DoChanged(Sender: TObject);
begin
if Assigned(FOnChange) then
FOnChange(Self);
UpdateGradient;
end;
procedure TvgGradientEdit.SetCurrentPoint(const Value: integer);
begin
if FCurrentPoint <> Value then
begin
FCurrentPoint := Value;
if Assigned(OnSelectPoint) then
OnSelectPoint(Self);
if (FColorPicker <> nil) and (CurrentPoint >= 0) then
FColorPicker.Color := Gradient.Points[CurrentPoint].IntColor;
end;
end;
procedure TvgGradientEdit.Notification(AComponent: TComponent;
Operation: TOperation);
begin
inherited;
if (Operation = opRemove) and (AComponent = FColorPicker) then
ColorPicker := nil;
end;
procedure TvgGradientEdit.SetColorPicker(const Value: TvgColorPicker);
begin
FColorPicker := Value;
if (FColorPicker <> nil) and (CurrentPoint >= 0) then
FColorPicker.Color := Gradient.Points[CurrentPoint].IntColor;
end;
procedure TvgGradientEdit.UpdateGradient;
begin
if (FColorPicker <> nil) and (CurrentPoint >= 0) then
FColorPicker.Color := Gradient.Points[CurrentPoint].IntColor;
end;
{ TvgColorPanel }
constructor TvgColorPanel.Create(AOwner: TComponent);
begin
inherited;
FUseAlpha := true;
Width := 150;
Height := 150;
FAlphaTrack := TvgAlphaTrackBar.Create(Self);
FAlphaTrack.Parent := Self;
FAlphaTrack.Align := vaBottom;
FAlphaTrack.Stored := false;
FAlphaTrack.Locked := true;
FAlphaTrack.Padding.Rect := vgRect(0, 0, 15, 0);
FAlphaTrack.Height := 15;
FAlphaTrack.DisableFocusEffect := true;
FAlphaTrack.OnChange := DoAlphaChange;
FHueTrack := TvgHueTrackBar.Create(Self);
FHueTrack.Parent := Self;
FHueTrack.Align := vaRight;
FHueTrack.Stored := false;
FHueTrack.Locked := true;
FHueTrack.Padding.Rect := vgRect(0, 0, 0, 0);
FHueTrack.Orientation := vgVertical;
FHueTrack.Width := 15;
FHueTrack.DisableFocusEffect := true;
FHueTrack.OnChange := DoHueChange;
FColorQuad := TvgColorQuad.Create(Self);
FColorQuad.Parent := Self;
FColorQuad.Align := vaClient;
FColorQuad.Stored := false;
FColorQuad.Locked := true;
FColorQuad.Padding.Rect := vgRect(5, 5, 3, 3);
FColorQuad.OnChange := DoQuadChange;
Color := vcWhite;
end;
procedure TvgColorPanel.Cleanup;
begin
inherited;
end;
procedure TvgColorPanel.DoAlphaChange(Sender: TObject);
begin
FColorQuad.Alpha := FAlphaTrack.Value;
end;
procedure TvgColorPanel.DoHueChange(Sender: TObject);
begin
FColorQuad.Hue := FHueTrack.Value;
end;
procedure TvgColorPanel.DoQuadChange(Sender: TObject);
begin
if FColorBox <> nil then
FColorBox.Color := vgStrToColor(Color);
if Assigned(OnChange) then
OnChange(Self);
end;
function TvgColorPanel.GetColor: string;
begin
Result := vgColorToStr(vgOpacity(vgHSLtoRGB(FColorQuad.Hue, FColorQuad.Sat, FColorQuad.Lum), FColorQuad.Alpha));
end;
procedure TvgColorPanel.Loaded;
begin
inherited;
Color := Color;
end;
procedure TvgColorPanel.Notification(AComponent: TComponent;
Operation: TOperation);
begin
inherited;
if (Operation = opRemove) and (AComponent = FColorBox) then
ColorBox := nil;
end;
procedure TvgColorPanel.SetColor(const Value: string);
var
H, S, L: single;
C: TvgColor;
SaveOnChange: TNotifyEvent;
begin
SaveOnChange := FOnChange;
FOnChange := nil;
C := vgStrToColor(Value);
vgRGBtoHSL(C, H, S, L);
FColorQuad.Lum := L;
FColorQuad.Sat := S;
FHueTrack.Value := H;
FAlphaTrack.Value := TvgColorRec(C).A / $FF;
FOnChange := SaveOnChange;
if not (csLoading in ComponentState) then
DoQuadChange(Self);
end;
procedure TvgColorPanel.SetColorBox(const Value: TvgColorBox);
begin
if FColorBox <> Value then
begin
FColorBox := Value;
if FColorBox <> nil then
FColorBox.Color := vgStrToColor(Color);
end;
end;
procedure TvgColorPanel.SetUseAlpha(const Value: boolean);
begin
if FUseAlpha <> Value then
begin
FUseAlpha := Value;
FAlphaTrack.Visible := FUseAlpha;
end;
end;
{ TvgComboColorBox }
constructor TvgComboColorBox.Create(AOwner: TComponent);
begin
inherited;
Width := 60;
Height := 22;
CanFocused := true;
AutoCapture := true;
FResource := 'comboboxstyle';
FPopup := TvgPopup.Create(Self);
FPopup.FResource := 'combopopupstyle';
FPopup.PlacementTarget := Self;
FPopup.StaysOpen := false;
FPopup.Stored := false;
FPopup.Parent := Self;
FPopup.Locked := true;
{$IfDef vgDesign}
FPopup.DesignHide := true;
{$EndIf vgDesign}
FPopup.Width := 240;
FPopup.Height := 160;
FPopup.Margins.Rect := vgRect(5, 5, 5, 5);
FColorBox := TvgColorBox.Create(Self);
FColorBox.Width := 50;
FColorBox.Parent := FPopup;
FColorBox.Stored := false;
FColorBox.Align := vaRight;
FColorBox.Padding.Rect := vgRect(15, 70, 15, 30);
FColorText := TvgTextBox.Create(Self);
FColorText.Parent := FPopup;
FColorText.Stored := false;
FColorText.Locked := true;
FColorText.FilterChar := '#0123456789abcdefABCDEF';
FColorText.SetBounds(160, 20, 70, 22);
FColorText.Align := vaTopRight;
FColorText.DisableFocusEffect := true;
FColorText.OnChange := DoTextChange;
FColorPanel := TvgColorPanel.Create(Self);
FColorPanel.Parent := FPopup;
FColorPanel.Stored := false;
FColorPanel.DisableFocusEffect := true;
FColorPanel.Align := vaClient;
FColorPanel.OnChange := DoColorChange;
FColorPanel.ColorBox := FColorBox;
end;
procedure TvgComboColorBox.Cleanup;
begin
inherited;
end;
procedure TvgComboColorBox.DoTextChange(Sender: TObject);
var
S: string;
begin
try
S := Color;
Color := FColorText.Text;
except
Color := S;
end;
end;
procedure TvgComboColorBox.DoColorChange(Sender: TObject);
begin
FColorText.Text := Color;
Repaint;
if Assigned(FOnChange) then
FOnChange(Self);
end;
procedure TvgComboColorBox.DropDown;
var
i: integer;
begin
if not FPopup.IsOpen then
begin
FPopup.Placement := FPlacement;
FColorPanel.ApplyResource;
FPopup.IsOpen := true;
end
else
begin
FPopup.IsOpen := false;
end;
end;
procedure TvgComboColorBox.MouseDown(Button: TMouseButton;
Shift: TShiftState; X, Y: single);
begin
inherited;
if (Button = mbLeft) then
begin
DropDown;
end;
end;
{$IfNDef Nemesis}
procedure TvgComboColorBox.ChangeParent;
begin
inherited;
end;
{$EndIf Nemesis}
function TvgComboColorBox.GetValue: string;
begin
Result := FColorPanel.Color
end;
procedure TvgComboColorBox.SetValue(const Value: string);
begin
FColorPanel.Color := Value;
end;
procedure TvgComboColorBox.ApplyStyle;
var
T: TvgObject;
begin
inherited;
T := FindResource('Content');
if (T <> nil) and (T is TvgContent) then
begin
TvgContent(T).OnPaint := DoContentPaint;
end;
end;
procedure TvgComboColorBox.DoContentPaint(Sender: TObject;
Canvas: TvgCustomCanvas; const ARect: TvgRect);
var
R: TvgRect;
i, j, SaveIndex: integer;
begin
R := ARect;
vgInflateRect(R, -0.5 - 2, -0.5 - 2);
{ draw back }
SaveIndex := TvgCanvas(Canvas).SaveCanvas;
TvgCanvas(Canvas).IntersectClipRect(R);
TvgCanvas(Canvas).Stroke.Style := vgBrushNone;
TvgCanvas(Canvas).Fill.Style := vgBrushSolid;
TvgCanvas(Canvas).Fill.SolidColor := $FFFFFFFF;
TvgCanvas(Canvas).FillRect(R, 0, 0, AllCorners, AbsoluteOpacity);
TvgCanvas(Canvas).Fill.SolidColor := $FFD3D3D3;
for i := 0 to Trunc(vgRectWidth(R) / 5) + 1 do
for j := 0 to Trunc(vgRectHeight(R) / 5) + 1 do
begin
if Odd(i + j) then
begin
TvgCanvas(Canvas).FillRect(vgRect(i * 5, j * 5, (i + 1) * 5, (j + 1) * 5), 0, 0, AllCorners, AbsoluteOpacity);
end;
end;
{ color }
TvgCanvas(Canvas).RestoreCanvas(SaveIndex);
TvgCanvas(Canvas).Fill.Style := vgBrushSolid;
TvgCanvas(Canvas).Fill.Color := Color;
TvgCanvas(Canvas).FillRect(R, 0, 0, AllCorners, AbsoluteOpacity);
TvgCanvas(Canvas).Stroke.Color := vcBlack;
TvgCanvas(Canvas).Stroke.Style := vgBrushSolid;
TvgCanvas(Canvas).DrawRect(R, 0, 0, AllCorners, AbsoluteOpacity);
end;
function TvgComboColorBox.GetUseAlpha: boolean;
begin
Result := FColorPanel.UseAlpha;
end;
procedure TvgComboColorBox.SetUseAlpha(const Value: boolean);
begin
FColorPanel.UseAlpha := Value;
end;
function TvgComboColorBox.GetData: Variant;
begin
Result := Color;
end;
procedure TvgComboColorBox.SetData(const Value: Variant);
begin
if VarIsEvent(Value) then
Onchange := VariantToEvent(Value)
else
if VarIsStr(Value) then
Color := Value
else
if VarIsOrdinal(Value) then
Color := vgColorToStr(Value);
end;
{ TvgHudHueTrackBar }
constructor TvgHudHueTrackBar.Create(AOwner: TComponent);
begin
inherited;
FResource := 'hudtrackbarstyle';
end;
{ TvgHudAlphaTrackBar }
constructor TvgHudAlphaTrackBar.Create(AOwner: TComponent);
begin
inherited;
FResource := 'hudtrackbarstyle';
end;
{ TvgHudBWTrackBar }
constructor TvgHudBWTrackBar.Create(AOwner: TComponent);
begin
inherited;
FResource := 'hudtrackbarstyle';
end;
{ TvgHudComboColorBox }
constructor TvgHudComboColorBox.Create(AOwner: TComponent);
begin
inherited;
FResource := 'hudcomboboxstyle';
FPopup.FResource := 'hudcombopopupstyle';
end;
initialization
RegisterVGObjects('Colors', [TvgHueTrackBar, TvgAlphaTrackBar, TvgBWTrackBar, TvgColorQuad, TvgColorPicker, TvgGradientEdit, TvgColorBox, TvgColorPanel, TvgComboColorBox]);
RegisterVGObjects('HUD', [TvgHudHueTrackBar, TvgHudAlphaTrackBar, TvgHudBWTrackBar, TvgHudComboColorBox]);
end.
|
unit ElevationMoniker;
{$WARN SYMBOL_PLATFORM OFF}
interface
uses
Winapi.Windows, Winapi.ActiveX, System.Classes, System.Win.ComObj, ADCommander_TLB,
System.SysUtils, System.Win.Registry, System.Variants, Vcl.AxCtrls, System.AnsiStrings,
System.StrUtils, ADOX_TLB, ElevationMonikerFactory, MSXML2_TLB, ADC.Types, ADC.Attributes,
ADC.ExcelEnum;
type
TADCElevationMoniker = class(TTypedComObject, IElevationMoniker)
private
const KEY_WOW64: array [0..1] of DWORD = (KEY_WOW64_32KEY, KEY_WOW64_64KEY);
private
procedure GenerateFields(ATable: Table; const AFieldCatalog: IUnknown;
APrimaryKeyName: string); overload;
procedure GenerateFields(AWorksheet: IDispatch; const AFieldCatalog: IUnknown); overload;
protected
procedure RegisterUCMAComponents(AClassID: PWideChar); safecall;
procedure UnregisterUCMAComponents(AClassID: PWideChar); safecall;
procedure SaveControlEventsList(AFileName: PWideChar; const AXMLStream: IUnknown); safecall;
procedure DeleteControlEventsList(AFileName: PWideChar); safecall;
function CreateAccessDatabase(AConnectionString: PWideChar; const AFieldCatalog: IUnknown): IUnknown; safecall;
function CreateExcelBook(const AFieldCatalog: IUnknown): IDispatch; safecall;
procedure SaveExcelBook(const ABook: IDispatch; AFileName: PWideChar; AFormat: Shortint); safecall;
public
end;
implementation
uses System.Win.ComServ;
{ TADCElevationMoniker }
function TADCElevationMoniker.CreateAccessDatabase(AConnectionString: PWideChar;
const AFieldCatalog: IUnknown): IUnknown;
var
oCatalog: Catalog;
oTable: Table;
begin
Result := nil;
try
oCatalog := CoCatalog.Create;
oCatalog.Create(string(AConnectionString));
// Users
oTable := CoTable.Create;;
oTable.ParentCatalog := oCatalog;
oTable.Name := EXPORT_TABNAME_USERS;
GenerateFields(oTable, AFieldCatalog, 'UserID');
oCatalog.Tables.Append(oTable);
// Groups
oTable := CoTable.Create;;
oTable.ParentCatalog := oCatalog;
oTable.Name := EXPORT_TABNAME_GROUPS;
GenerateFields(oTable, AFieldCatalog, 'GroupID');
oCatalog.Tables.Append(oTable);
// Computers
oTable := CoTable.Create;;
oTable.ParentCatalog := oCatalog;
oTable.Name := EXPORT_TABNAME_WORKSTATIONS;
GenerateFields(oTable, AFieldCatalog, 'ComputerID');
oCatalog.Tables.Append(oTable);
// // Groups Membership
// oTable := CoTable.Create;;
// oTable.ParentCatalog := oCatalog;
// oTable.Name := 'Membership';
// oTable.Columns.Append('Group', adLongVarWChar, 0);
// oTable.Columns.Append('Member', adLongVarWChar, 0);
// oCatalog.Tables.Append(oTable);
Result := oCatalog;
finally
oTable := nil;
end;
end;
function TADCElevationMoniker.CreateExcelBook(const AFieldCatalog: IInterface): IDispatch;
var
SaveAsFormat: Integer;
oExcelBook: Variant;
oSheet: Variant;
begin
oExcelBook := CreateOleObject('Excel.Application');
oExcelBook.Workbooks.Add(xlWBATWorksheet);
oExcelBook.DisplayAlerts := False;
oExcelBook.Calculation := xlCalculationManual;
oExcelBook.EnableEvents := False;
oExcelBook.ScreenUpdating := False;
// Лист "Users"
oExcelBook.ActiveWindow.SplitRow := 1;
// oExcelBook.ActiveWindow.SplitColumn := 1;
oExcelBook.ActiveWindow.FreezePanes := True;
oExcelBook.Workbooks[1].WorkSheets[1].Name := EXPORT_TABNAME_USERS;
oSheet := oExcelBook.Workbooks[1].Worksheets[EXPORT_TABNAME_USERS];
GenerateFields(oSheet, AFieldCatalog);
// Лист "Groups"
oExcelBook.Workbooks[1].WorkSheets.Add(
EmptyParam, //Before: An object that specifies the sheet before which the new sheet is added.
oSheet, //After: An object that specifies the sheet after which the new sheet is added.
1, //Count: The number of sheets to be added. The default value is one.
xlWorksheet //Type: Specifies the sheet type. Can be one of the following XlSheetType constants: xlWorksheet, xlChart, xlExcel4MacroSheet, or xlExcel4IntlMacroSheet.
);
oExcelBook.ActiveWindow.SplitRow := 1;
oExcelBook.ActiveWindow.FreezePanes := True;
oExcelBook.Workbooks[1].WorkSheets[2].Name := EXPORT_TABNAME_GROUPS;
oSheet := oExcelBook.Workbooks[1].Worksheets[EXPORT_TABNAME_GROUPS];
GenerateFields(oSheet, AFieldCatalog);
// Лист "Workstations"
oExcelBook.Workbooks[1].WorkSheets.Add(
EmptyParam, //Before: An object that specifies the sheet before which the new sheet is added.
oSheet, //After: An object that specifies the sheet after which the new sheet is added.
1, //Count: The number of sheets to be added. The default value is one.
xlWorksheet //Type: Specifies the sheet type. Can be one of the following XlSheetType constants: xlWorksheet, xlChart, xlExcel4MacroSheet, or xlExcel4IntlMacroSheet.
);
oExcelBook.ActiveWindow.SplitRow := 1;
oExcelBook.ActiveWindow.FreezePanes := True;
oExcelBook.Workbooks[1].WorkSheets[3].Name := EXPORT_TABNAME_WORKSTATIONS;
oSheet := oExcelBook.Workbooks[1].Worksheets[EXPORT_TABNAME_WORKSTATIONS];
GenerateFields(oSheet, AFieldCatalog);
Result := oExcelBook;
end;
procedure TADCElevationMoniker.DeleteControlEventsList(AFileName: PWideChar);
begin
DeleteFileW(AFileName);
end;
procedure TADCElevationMoniker.GenerateFields(AWorksheet: IDispatch;
const AFieldCatalog: IInterface);
var
oSheet: Variant;
oRows: Variant;
oColumns: Variant;
i: Integer;
AttrCatalog: TAttrCatalog;
OleStream: TOleStream;
a: TADAttribute;
begin
oSheet := AWorksheet;
oSheet.EnableCalculation := False;
oRows := oSheet.Rows;
oRows.Rows[1].Font.Bold := True;
oColumns := oSheet.Columns;
OleStream := TOLEStream.Create((AFieldCatalog as IStream));
AttrCatalog := TAttrCatalog.Create;
AttrCatalog.LoadFromStream(OleStream);
try
for i := 0 to AttrCatalog.Count - 1 do
begin
a := AttrCatalog[i]^;
oColumns.Columns[i + 1].ColumnWidth := a.ExcelColumnWidth;
oColumns.Columns[i + 1].HorizontalAlignment := a.ExcelColumnAlignment;
oColumns.Columns[i + 1].NumberFormat := a.ExcelCellFormat(oSheet.Application);
oSheet.Cells[1, i + 1] := a.FieldName;
end;
finally
OleStream.Free;
AttrCatalog.Free;
end;
end;
procedure TADCElevationMoniker.GenerateFields(ATable: Table;
const AFieldCatalog: IInterface; APrimaryKeyName: string);
var
i: Integer;
k: Integer;
s: string;
FieldExists: Boolean;
FieldName: string;
FieldSize: Integer;
oIndex: Index;
AttrCatalog: TAttrCatalog;
OleStream: TOleStream;
a: PADAttribute;
begin
OleStream := TOLEStream.Create((AFieldCatalog as IStream));
AttrCatalog := TAttrCatalog.Create();
AttrCatalog.LoadFromStream(OleStream);
try
// ATable.Columns.Append(APrimaryKeyName, adInteger, 0);
// ATable.Columns[APrimaryKeyName].Properties['AutoIncrement'].Value := True;
//
// oIndex := CoIndex.Create;
// oIndex.Name := 'ObjectID';
// oIndex.Unique := True;
// oIndex.PrimaryKey := True;
// oIndex.Columns.Append(APrimaryKeyName, adInteger, 0);
//
// ATable.Indexes.Append(oIndex, Null);
for a in AttrCatalog do
begin
// Формируем имя поля
s := a^.FieldName;
FieldName := s;
// Ищем дубликаты и, если находим, добавляем к имени порядковый номер
k := 1;
while True do
begin
FieldExists := False;
for i := 0 to ATable.Columns.Count - 1 do
if CompareText(ATable.Columns[i].Name, FieldName) = 0 then
begin
Inc(k);
FieldExists := True;
FieldName := Format('%s (%d)', [s, k]);
Break;
end;
if not FieldExists then Break;
end;
//Добавляем поле в таблицу
case a^.ADODataType of
adLongVarWChar: FieldSize := 255;
else FieldSize := 0;
end;
ATable.Columns.Append(FieldName, a^.ADODataType, FieldSize);
ATable.Columns[FieldName].Properties['Nullable'].Value := True;
end;
finally
oIndex := nil;
OleStream.Free;
AttrCatalog.Free;
end;
end;
procedure TADCElevationMoniker.RegisterUCMAComponents(AClassID: PWideChar);
const
ProgID = 'ADCommander.UCMA';
ClassName = 'ADCommander.UCMA.UCMAContact';
var
Reg: TRegistry;
Res: Boolean;
Key: DWORD;
begin
Reg := TRegistry.Create();
Reg.RootKey := HKEY_CLASSES_ROOT;
for Key in KEY_WOW64 do
begin
Reg.Access := KEY_WRITE or Key;
{ [HKEY_CLASSES_ROOT\ADCommander.UCMA] }
Res := Reg.OpenKey(ProgID, True);
if Res then
begin
Reg.WriteString('', ClassName);
end;
Reg.CloseKey;
{ [HKEY_CLASSES_ROOT\ADCommander.UCMA\CLSID] }
Res := Reg.OpenKey(ProgID + '\CLSID', True);
if Res then
begin
Reg.WriteString('', AClassID);
end;
Reg.CloseKey;
{ [HKEY_CLASSES_ROOT\CLSID\%ClassID%] }
Res := Reg.OpenKey('CLSID\' + AClassID, True);
if Res then
begin
Reg.WriteString('', ClassName);
end;
Reg.CloseKey;
{ [HKEY_CLASSES_ROOT\CLSID\%ClassID%\InprocServer32] }
Res := Reg.OpenKey('CLSID\' + AClassID + '\InprocServer32', True);
if Res then
begin
Reg.WriteString('', 'mscoree.dll');
Reg.WriteString('ThreadingModel', 'Both');
Reg.WriteString('Class', ClassName);
Reg.WriteString('Assembly', 'adcmd.ucma, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null');
Reg.WriteString('RuntimeVersion', 'v2.0.50727');
end;
Reg.CloseKey;
{ [HKEY_CLASSES_ROOT\CLSID\%ClassID%\InprocServer32\1.0.0.0] }
Res := Reg.OpenKey('CLSID\' + AClassID + '\InprocServer32\1.2.0.0', True);
if Res then
begin
Reg.WriteString('Class', ClassName);
Reg.WriteString('Assembly', 'adcmd.ucma, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null');
Reg.WriteString('RuntimeVersion', 'v2.0.50727');
end;
Reg.CloseKey;
{ [HKEY_CLASSES_ROOT\CLSID\%ClassID%\ProgId] }
Res := Reg.OpenKey('CLSID\' + AClassID + '\ProgId', True);
if Res then
begin
Reg.WriteString('', ProgId);
end;
Reg.CloseKey;
Res := Reg.OpenKey('CLSID\' + AClassID + '\Implemented Categories\{62C8FE65-4EBB-45E7-B440-6E39B2CDBF29}', True);
Reg.CloseKey;
end;
Reg.Free;
end;
procedure TADCElevationMoniker.SaveControlEventsList(AFileName: PWideChar; const AXMLStream: IInterface);
var
xmlDoc: IXMLDOMDocument;
begin
xmlDoc := CoDOMDocument60.Create;
try
xmlDoc.async := False;
xmlDoc.load(AXMLStream as IStream);
if xmlDoc.parseError.errorCode = 0
then xmlDoc.save(string(AFileName));
except
end;
xmlDoc := nil;
end;
procedure TADCElevationMoniker.SaveExcelBook(const ABook: IDispatch;
AFileName: PWideChar; AFormat: Shortint);
var
SaveAsFormat: Integer;
ExcelApp: Variant;
i: Integer;
begin
ExcelApp := ABook;
for i := 1 to ExcelApp.WorkBooks[1].Worksheets.Count do
ExcelApp.WorkBooks[1].Worksheets[i].EnableCalculation := True;
ExcelApp.WorkBooks[1].Worksheets[1].Activate;
case TADCExportFormat(AFormat) of
efExcel2007 : SaveAsFormat := xlWorkbookDefault;
efExcel : SaveAsFormat := xlExcel8;
efCommaSeparated : SaveAsFormat := xlCSVWindows;
else SaveAsFormat := xlExcel8;
end;
ExcelApp.ActiveWorkBook.SaveAs(
string(AFileName), // Filename
SaveAsFormat, // FileFormat
EmptyParam, // Password
EmptyParam, // WriteResPassword
False, // ReadOnlyRecommended
False, // CreateBackup
EmptyParam, // AccessMode
EmptyParam, // ConflictResolution
False, // AddToMru
EmptyParam, // TextCodepage
EmptyParam, // TextVisualLayout
EmptyParam // Local
);
ExcelApp.Calculation := xlCalculationAutomatic;
ExcelApp.EnableEvents := True;
ExcelApp.ScreenUpdating := True;
ExcelApp.DisplayAlerts := True;
ExcelApp.ActiveWorkbook.RunAutoMacros(2);
ExcelApp.ActiveWorkbook.Close(False);
end;
procedure TADCElevationMoniker.UnregisterUCMAComponents(AClassID: PWideChar);
const
ProgID = 'ADCommander.UCMA';
var
Reg: TRegistry;
Res: Boolean;
Key: DWORD;
begin
Reg := TRegistry.Create();
Reg.RootKey := HKEY_CLASSES_ROOT;
for Key in KEY_WOW64 do
begin
Reg.Access := KEY_WRITE or Key;
Res := Reg.DeleteKey(ProgID + '\CLSID');
Res := Reg.DeleteKey(ProgID);
Res := Reg.DeleteKey('CLSID\' + AClassID + '\Implemented Categories\{62C8FE65-4EBB-45E7-B440-6E39B2CDBF29}');
Res := Reg.DeleteKey('CLSID\' + AClassID + '\Implemented Categories');
Res := Reg.DeleteKey('CLSID\' + AClassID + '\ProgId');
Res := Reg.DeleteKey('CLSID\' + AClassID + '\InprocServer32\1.2.0.0');
Res := Reg.DeleteKey('CLSID\' + AClassID + '\InprocServer32');
Res := Reg.DeleteKey('CLSID\' + AClassID);
Reg.CloseKey;
end;
Reg.Free;
end;
initialization
TElevationMonikerFactory.Create(
'101', // resource string id
'102', // resource icon id
ComServer,
TADCElevationMoniker,
CLASS_ElevationMoniker,
ciMultiInstance,
tmApartment
);
end.
|
{
1 правая - не четная, 2 левая - четная, сторона | мс5 0 лева 1 правая
}
unit sql;
interface
uses
SysUtils, Classes, Windows, ActiveX, Graphics, Forms, System.Variants,
ZAbstractDataset, ZDataset, ZAbstractConnection, ZConnection, ZAbstractRODataset,
ZStoredProcedure;
type
TIdHeat = Record
tid : integer;
Heat : string[26]; // плавка
Grade : string[50]; // марка стали
Section : string[50]; // профиль
Standard : string[50]; // стандарт
StrengthClass : string[50]; // клас прочности
c : string[50];
mn : string[50];
cr : string[50];
si : string[50];
b : string[50];
ce : string[50];
old_tid : integer; // стара плавка
marker : bool;
temperature : integer;
timestamp : integer;
LowRed : integer;
HighRed : integer;
LowGreen : integer;
HighGreen : integer;
constructor Create(_tid: integer; _Heat, _Grade, _Section, _Standard, _StrengthClass,
_c, _mn, _cr, _si, _b, _ce: string; _old_tid: integer; _marker: bool;
_temperature, _timestamp, _LowRed, _HighRed, _LowGreen, _HighGreen
: integer);
end;
var
PConnect: TZConnection;
PQuery: TZQuery;
left, right: TIdHeat;
function ConfigPostgresSetting(InData: bool): bool;
function SqlReadCurrentHeat: bool;
function ViewCurrentData: bool;
function ReadLastHeat(InTid, InSide: integer): integer;
// {$DEFINE DEBUG}
implementation
uses
main, logging, settings, chart;
function ConfigPostgresSetting(InData: bool): bool;
begin
if InData then
begin
PConnect := TZConnection.Create(nil);
PQuery := TZQuery.Create(nil);
try
PConnect.LibraryLocation := CurrentDir + '\'+ PgSqlConfigArray[3];
PConnect.Protocol := 'postgresql-9';
PConnect.HostName := PgSqlConfigArray[1];
PConnect.Port := strtoint(PgSqlConfigArray[6]);
PConnect.User := PgSqlConfigArray[4];
PConnect.Password := PgSqlConfigArray[5];
PConnect.Database := PgSqlConfigArray[2];
PConnect.Connect;
PQuery.Connection := PConnect;
except
on E: Exception do
SaveLog('error' + #9#9 + E.ClassName + ', с сообщением: ' + E.Message);
end;
end
else
begin
FreeAndNil(PQuery);
FreeAndNil(PConnect);
end;
end;
function SqlReadCurrentHeat: bool;
var
i: integer;
begin
for i := 0 to 1 do
begin
// side left=0, side right=1
PQuery.Close;
PQuery.sql.Clear;
PQuery.sql.Add('select t1.tid, t1.heat, t1.strength_class, t1.section,');
PQuery.sql.Add('t1.temperature, t1.timestamp,');
PQuery.sql.Add('t2.grade, t2.standard, t2.c, t2.mn, t2.cr, t2.si, t2.b,');
PQuery.sql.Add('cast(t2.c+(mn/6)+(cr/5)+((si+b)/10) as numeric(4,2))||'' (''||t4.ce_category||'')'' as ce,');
PQuery.sql.Add('t3.low as low_red, t3.high as high_red, t4.low as low_green, t4.high as high_green');
PQuery.sql.Add('FROM temperature_current t1');
PQuery.sql.Add('LEFT OUTER JOIN');
PQuery.sql.Add('chemical_analysis t2');
PQuery.sql.Add('on t1.heat=t2.heat');
PQuery.sql.Add('LEFT OUTER JOIN');
PQuery.sql.Add('calculated_data t3');
PQuery.sql.Add('on t1.tid=t3.cid');
PQuery.sql.Add('and t3.step = 0');
PQuery.sql.Add('LEFT OUTER JOIN');
PQuery.sql.Add('calculated_data t4');
PQuery.sql.Add('on t1.tid=t4.cid');
PQuery.sql.Add('and t4.step = 1');
PQuery.sql.Add('where t1.side='+inttostr(i)+'');
PQuery.sql.Add('order by t1.timestamp desc LIMIT 1');
PQuery.Open;
if i = 0 then
begin
left.tid := PQuery.FieldByName('tid').AsInteger;
left.Heat := PQuery.FieldByName('heat').AsString;
left.Grade := PQuery.FieldByName('grade').AsString;
left.StrengthClass := PQuery.FieldByName('strength_class').AsString;
left.Section := PQuery.FieldByName('section').AsString;
left.Standard := PQuery.FieldByName('standard').AsString;
left.c := PQuery.FieldByName('c').AsString;
left.mn := PQuery.FieldByName('mn').AsString;
left.cr := PQuery.FieldByName('cr').AsString;
left.si := PQuery.FieldByName('si').AsString;
left.b := PQuery.FieldByName('b').AsString;
left.ce := PQuery.FieldByName('ce').AsString;
left.temperature := PQuery.FieldByName('temperature').AsInteger;
left.timestamp := PQuery.FieldByName('timestamp').AsInteger;
left.LowRed := PQuery.FieldByName('low_red').AsInteger;
left.HighRed := PQuery.FieldByName('high_red').AsInteger;
left.LowGreen := PQuery.FieldByName('low_green').AsInteger;
left.HighGreen := PQuery.FieldByName('high_green').AsInteger;
if left.old_tid = 0 then
left.old_tid := ReadLastHeat(left.tid, i);
// новая плавка устанавливаем маркер
if left.old_tid <> left.tid then
begin
left.old_tid := left.tid;
left.marker := true;
left.LowRed := 0;
left.HighRed := 0;
left.LowGreen := 0;
left.HighGreen := 0;
end;
end
else
begin
right.tid := PQuery.FieldByName('tid').AsInteger;
right.Heat := PQuery.FieldByName('heat').AsString;
right.Grade := PQuery.FieldByName('grade').AsString;
right.StrengthClass := PQuery.FieldByName('strength_class').AsString;
right.Section := PQuery.FieldByName('section').AsString;
right.Standard := PQuery.FieldByName('standard').AsString;
right.c := PQuery.FieldByName('c').AsString;
right.mn := PQuery.FieldByName('mn').AsString;
right.cr := PQuery.FieldByName('cr').AsString;
right.si := PQuery.FieldByName('si').AsString;
right.b := PQuery.FieldByName('b').AsString;
right.ce := PQuery.FieldByName('ce').AsString;
right.temperature := PQuery.FieldByName('temperature').AsInteger;
right.timestamp := PQuery.FieldByName('timestamp').AsInteger;
right.LowRed := PQuery.FieldByName('low_red').AsInteger;
right.HighRed := PQuery.FieldByName('high_red').AsInteger;
right.LowGreen := PQuery.FieldByName('low_green').AsInteger;
right.HighGreen := PQuery.FieldByName('high_green').AsInteger;
if right.old_tid = 0 then
right.old_tid := ReadLastHeat(right.tid, i);
// новая плавка устанавливаем маркер
if right.old_tid <> right.tid then
begin
right.old_tid := right.tid;
right.marker := true;
right.LowRed := 0;
right.HighRed := 0;
right.LowGreen := 0;
right.HighGreen := 0;
end;
end;
end;
ViewCurrentData;
if left.marker then
begin
left.marker := false;
ShowTrayMessage('информация','новая плавка: '+left.heat,1);
end;
if right.marker then
begin
right.marker := false;
ShowTrayMessage('информация','новая плавка: '+right.heat,1);
end;
end;
function ViewCurrentData: bool;
begin
// side left
form1.l_global_left.Caption := 'плавка: ' + left.Heat + ' | ' + 'марка: ' +
left.Grade + ' | ' + 'класс прочности: ' + left.StrengthClass + ' | ' +
'профиль: ' + left.Section + ' | ' + 'стандарт: ' + left.Standard;
form1.l_chemical_left.Caption := 'химический анализ' + #9 + 'C: ' + left.c +
' | ' + 'Mn: ' + left.mn + ' | ' + 'Si: ' + left.si + ' | ' +
'Cr: ' + left.cr + ' | ' + 'B: ' + left.b + ' | ' + 'Ce: ' + left.ce;
// side right
form1.l_global_right.Caption := 'плавка: ' + right.Heat + ' | ' + 'марка: ' +
right.Grade + ' | ' + 'класс прочности: ' + right.StrengthClass + ' | ' +
'профиль: ' + right.Section + ' | ' + 'стандарт: ' + right.Standard;
form1.l_chemical_right.Caption := 'химический анализ' + #9 + 'C: ' + right.c +
' | ' + 'Mn: ' + right.mn + ' | ' + 'Si: ' + right.si + ' | ' +
'Cr: ' + right.cr + ' | ' + 'B: ' + right.b + ' | ' + 'Ce: ' + right.ce;
end;
function ReadLastHeat(InTid, InSide: integer): integer;
var
tid: integer;
begin
try
SQuery.Close;
SQuery.SQL.Clear;
SQuery.SQL.Add('SELECT * FROM settings');
SQuery.Open;
except
on E: Exception do
SaveLog('error' + #9#9 + E.ClassName + ', с сообщением: ' + E.Message);
end;
while not SQuery.Eof do
begin
if SQuery.FieldByName('name').AsString = '::tid::side'+inttostr(InSide) then
tid := SQuery.FieldByName('value').AsInteger;
SQuery.Next;
end;
if tid <> InTid then
begin
try
SQuery.Close;
SQuery.SQL.Clear;
SQuery.SQL.Add('INSERT OR REPLACE INTO settings (name, value)');
SQuery.SQL.Add('VALUES (''::tid::side'+inttostr(InSide)+''',');
SQuery.SQL.Add(''''+inttostr(InTid)+''')');
SQuery.ExecSQL;
except
on E: Exception do
SaveLog('error' + #9#9 + E.ClassName + ', с сообщением: ' + E.Message);
end;
result := InTid;
end
else
result := tid
end;
constructor TIdHeat.Create(_tid: integer; _Heat, _Grade, _Section, _Standard, _StrengthClass,
_c, _mn, _cr, _si, _b, _ce: string; _old_tid: integer; _marker: bool;
_temperature, _timestamp, _LowRed, _HighRed, _LowGreen, _HighGreen
: integer);
begin
tid := _tid;
Heat := _Heat; // плавка
Grade := _Grade; // марка стали
Section := _Section; // профиль
Standard := _Standard; // стандарт
StrengthClass := _StrengthClass; // клас прочности
c := _c;
mn := _mn;
cr := _cr;
si := _si;
b := _b;
ce := _ce;
old_tid := _old_tid; // стара плавка
marker := _marker;
temperature := _temperature;
timestamp := _timestamp;
LowRed := _LowRed;
HighRed := _HighRed;
LowGreen := _LowGreen;
HighGreen := _HighGreen;
end;
// При загрузке программы класс будет создаваться
initialization
left := TIdHeat.Create(0,'','','','','','','','','','','',0,false,0,0,0,0,0,0);
right := TIdHeat.Create(0,'','','','','','','','','','','',0,false,0,0,0,0,0,0);
// При закрытии программы уничтожаться
finalization
FreeAndNil(left);
FreeAndNil(right);
end.
|
{-------------------------------------------------------------------------------
This unit contains:
o the dos decompression algorithm, based on the c-code of ccexplore.
o a dos compression algorithm, based on free basic code of Mindless
o an easy to use sectionlist
-------------------------------------------------------------------------------}
{$include lem_directives.inc}
unit LemDosCmp;
interface
uses
Classes, SysUtils, Math, Contnrs,
UMisc,
LemTypes;
type
{-------------------------------------------------------------------------------
This header is at each section of compressed data.
o Watch out: the words are Big Endian so swap when reading or writing!!!
o Compressed size includes this 10 bytes header
o Never change this declaration
-------------------------------------------------------------------------------}
TCompressionHeaderRec = packed record
BitCnt : Byte;
Checksum : Byte;
Unused1 : Word;
DecompressedSize : Word;
Unused2 : Word;
CompressedSize : Word;
end;
{-------------------------------------------------------------------------------
TDecompressorStateRec is internally used when decompressing
-------------------------------------------------------------------------------}
type
TDecompressorStateRec = record
BitCnt : Byte;
CurBits : Byte;
Cdata : PBytes;
Cptr : Integer;
Ddata : PBytes;
Dptr : Integer;
Checksum : Integer;
CSize : Integer; // added for read validation
DSize : Integer; // added for write validation
end;
type
{-------------------------------------------------------------------------------
two classes to split up dos dat file in sections and keep in mem
-------------------------------------------------------------------------------}
TDosDatSection = class
private
fCompressedData : TMemoryStream;
fDecompressedData : TMemoryStream; {Memory}
protected
public
constructor Create;
destructor Destroy; override;
property CompressedData : TMemoryStream read fCompressedData;
property DecompressedData : TMemoryStream read fDecompressedData; {Memory}
end;
type
TDosDatSectionList = class(TObjectList)
private
function GetItem(Index: Integer): TDosDatSection;
procedure SetItem(Index: Integer; const Value: TDosDatSection);
protected
public
function Add(Item: TDosDatSection): Integer;
procedure Insert(Index: Integer; Item: TDosDatSection);
property Items[Index: Integer]: TDosDatSection read GetItem write SetItem; default;
end;
type
TDosDatDecompressor = class
private
fSkipErrors: Boolean;
function ValidSrc(const State: TDecompressorStateRec; aIndex: Integer): Boolean;
function ValidDst(const State: TDecompressorStateRec; aIndex: Integer): Boolean;
function CheckSrc(const State: TDecompressorStateRec; aIndex: Integer): Boolean;
function CheckDst(const State: TDecompressorStateRec; aIndex: Integer): Boolean;
protected
function GetNextBits(n: integer; var State: TDecompressorStateRec): Integer;
procedure CopyPrevData(aBlocklen, aOffsetSize: Integer; var State: TDecompressorStateRec);
procedure DumpData(Numbytes: Integer; var State: TDecompressorStateRec);
function Decompress(aCompData, aDecompData: PBytes; aBitCnt: Byte; aCompSize, aDecompSize: Integer): Integer;
public
{ core routine }
function DecompressSection(SrcStream, DstStream: TStream): Integer;
{ higher }
function LoadSection(SrcStream: TStream; Sec: TDosDatSection; DecompressOnTheFly: Boolean = True): Boolean;
procedure LoadSectionList(SrcStream: TStream; aList: TDosDatSectionList; DecompressOnTheFly: Boolean = True);
procedure LoadSectionListFromFile(const aFileName: string; aList: TDosDatSectionList; DecompressOnTheFly: Boolean = True);
property SkipErrors: Boolean read fSkipErrors write fSkipErrors;
end;
type
TProgressEvent = procedure(aPosition, aMaximum: Integer) of object;
type
TDosDatCompressor = class
private
DSize : Word;
CSize : Word;
di : Word; // index of source data byte
ci : Word; // index of dest data byte
BitCnt : Byte;
CData : PBytes;
DData : PBytes;
fOnProgress : TProgressEvent;
protected
procedure InternalCompress;
function FindLongRef(var Len: Word): Word;
function FindRef(Len: Word): Word;
procedure EncodeRawChunk(var Len: Word);
procedure PushNextBits(n, bits: word);
public
procedure CompressFile(const aFileName, aDstFile: string); // obsolete
{ core method }
function Compress(Src, Dst: TStream): Integer;
{ higher methods }
procedure StoreSection(aList: TDosDatSection; DstStream: TStream;
CompressOnTheFly: Boolean = True);
procedure StoreSectionList(aList: TDosDatSectionList; DstStream: TStream;
CompressOnTheFly: Boolean = True);
property OnProgress: TProgressEvent read fOnProgress write fOnProgress;
end;
const
COMPRESSIONHEADER_SIZE = SizeOf(TCompressionHeaderRec);
type
EDecompressError = class(Exception);
implementation
resourcestring
SDecompressorSrcError_ddddddd = 'Decompress error. ' +
'Attempt to read or write source data at index %d. ' +
'BitCnt=%d, ' +
'CurBits=%d, ' +
'Cptr=%d, ' +
'Dptr=%d, ' +
'CSize=%d, ' +
'DSize=%d';
SDecompressorDstError_ddddddd = 'Decompress error. ' +
'Attempt to read or write destination data at index %d. ' +
'BitCnt=%d, ' +
'CurBits=%d, ' +
'Cptr=%d, ' +
'Dptr=%d, ' +
'CSize=%d, ' +
'DSize=%d';
{ TDosDatDecompressor }
function TDosDatDecompressor.ValidSrc(const State: TDecompressorStateRec; aIndex: Integer): Boolean;
begin
Result := (aIndex < State.CSize) and (aIndex >= 0);
end;
function TDosDatDecompressor.ValidDst(const State: TDecompressorStateRec; aIndex: Integer): Boolean;
begin
Result := (aIndex < State.DSize) and (aIndex >= 0);
end;
function TDosDatDecompressor.CheckSrc(const State: TDecompressorStateRec; aIndex: Integer): Boolean;
begin
Result := ValidSrc(State, aIndex);
if not Result and not SkipErrors then
with State do
raise EDecompressError.CreateFmt(SDecompressorSrcError_ddddddd,
[aIndex, BitCnt, CurBits, Cptr, Dptr, CSize, DSize]);
end;
function TDosDatDecompressor.CheckDst(const State: TDecompressorStateRec; aIndex: Integer): Boolean;
begin
Result := ValidDst(State, aIndex);
if not Result and not SkipErrors then
with State do
raise EDecompressError.CreateFmt(SDecompressorDstError_ddddddd,
[aIndex, BitCnt, CurBits, Cptr, Dptr, CSize, DSize]);
end;
function TDosDatDecompressor.GetNextBits(N: integer; var State: TDecompressorStateRec): Integer;
begin
Result := 0;
while n > 0 do
begin
Dec(State.BitCnt);
if State.BitCnt = 0 then
begin
Dec(State.Cptr);
CheckSrc(State, State.CPtr);
State.CurBits := State.Cdata^[State.Cptr];
State.Checksum := State.CheckSum xor State.Curbits;
State.BitCnt := 8;
end;
Result := Result shl 1;
Result := Result or (State.CurBits and 1);
State.CurBits := State.CurBits shr 1;
Dec(n);
end;
end;
procedure TDosDatDecompressor.CopyPrevData(aBlocklen, aOffsetSize: Integer; var State: TDecompressorStateRec);
var
i, Offset: Integer;
begin
Offset := GetNextBits(aOffsetSize, State);
for i := 0 to aBlockLen - 1 do
begin
Dec(State.Dptr);
CheckDst(State, State.DPtr);
CheckDst(State, State.DPtr + Offset + 1);
State.Ddata^[State.Dptr] := State.Ddata^[State.Dptr + Offset + 1];
end;
end;
procedure TDosDatDecompressor.DumpData(Numbytes: Integer; var State: TDecompressorStateRec);
var
B: Byte;
begin
while NumBytes > 0 do
begin
Dec(State.Dptr);
B := Byte(GetNextBits(8, State));
CheckDst(State, State.DPtr);
State.Ddata^[State.Dptr] := B;
Dec(NumBytes);
end;
end;
function TDosDatDecompressor.Decompress(aCompData, aDecompData: PBytes;
aBitCnt: Byte; aCompSize, aDecompSize: Integer): Integer;
var
State: TDecompressorStateRec;
begin
FillChar(State, SizeOf(State), 0);
State.BitCnt := aBitCnt + 1;
State.Cptr := aCompSize - 1;
State.Dptr := aDecompSize;
State.Cdata := aCompdata;
State.Ddata := aDecompData;
State.CurBits := aCompdata^[State.Cptr];
State.Checksum := State.CurBits;
State.CSize := aCompSize;
State.DSize := aDecompSize;
while State.Dptr > 0 do
begin
if (GetNextBits(1, State) = 1) then
begin
case GetNextBits(2, State) of
0: CopyPrevData(3, 9, State);
1: CopyPrevData(4, 10, State);
2: CopyPrevData(GetNextBits(8, State) + 1, 12, State);
3: DumpData(GetNextBits(8, State) + 9, State);
end;
end
else begin
case GetNextBits(1, State) of
0: DumpData(GetNextBits(3, State) + 1, State);
1: CopyPrevData(2, 8, State);
end;
end;
end;
Result := State.Checksum;
end;
function TDosDatDecompressor.DecompressSection(SrcStream, DstStream: TStream): Integer;
{-------------------------------------------------------------------------------
Code for decompressing one section from source stream to destination stream.
There can be more sections in a file of course
o None of the positions of the streams is changed before decompression!
So be sure you're at the right position.
o Return value is the number of decompressed bytes.
o The compression-header must be included in the SrcStream.
o The data is read en written at the current positions of the streams.
-------------------------------------------------------------------------------}
var
Rd: Integer;
Header: TCompressionHeaderRec;
SrcData, DstData: PBytes;
ComputedChecksum: Integer;
CSize, DSize: Integer;
begin
Assert(COMPRESSIONHEADER_SIZE = 10, 'Program error DecompressSection');
Result := 0;
FillChar(Header, SizeOf(Header), 0);
Rd := SrcStream.Read(Header, COMPRESSIONHEADER_SIZE);
if Rd <> COMPRESSIONHEADER_SIZE then
Exit;
CSize := System.Swap(Header.CompressedSize) + (System.Swap(Header.Unused2) shl 16); // convert from bigendian
Dec(CSize, COMPRESSIONHEADER_SIZE); // exclude the headersize which is included in this size
DSize := System.Swap(Header.DecompressedSize) + (System.Swap(Header.Unused1) shl 16); // convert from bigendian
GetMem(SrcData, CSize);
GetMem(DstData, DSize);
try
FillChar(SrcData^, CSize, 0);
FillChar(DstData^, DSize, 0);
SrcStream.ReadBuffer(SrcData^, CSize);
ComputedChecksum := Decompress(SrcData, DstData, Header.BitCnt, CSize, DSize);
if ComputedCheckSum <> Header.Checksum then
raise Exception.Create('Checksum error occurred during decompression');
DstStream.WriteBuffer(DstData^, DSize);
Result := DSize;
finally
FreeMem(SrcData);
FreeMem(DstData);
end;
end;
function TDosDatDecompressor.LoadSection(SrcStream: TStream;
Sec: TDosDatSection; DecompressOnTheFly: Boolean): Boolean;
var
Header: TCompressionHeaderRec;
Rd: Integer;
CopySize: Integer;
CSize, DSize: Integer;
begin
Rd := SrcStream.Read(Header, SizeOf(Header));
Result := Rd <> 0;
if not Result then
Exit;
if Rd <> SizeOf(Header) then
raise Exception.Create('Decompressor Header Error');
CSize := System.Swap(Header.CompressedSize) + (System.Swap(Header.Unused2) shl 16);
CopySize := CSize;
Dec(CSize, 10); // exclude the headersize which is included in this size
DSize := System.Swap(Header.DecompressedSize) + (System.Swap(Header.Unused1) shl 16);
SrcStream.Seek(-SizeOf(Header), soFromCurrent); // go back for copying in section object data
// Sec.fDecompressedSize := Header.DecompressedSize;
// Sec.fCompressedSize := Header.CompressedSize;
Sec.CompressedData.CopyFrom(SrcStream, CopySize);
if DecompressOnTheFly then
begin
Sec.CompressedData.Seek(0, soFromBeginning);
DecompressSection(Sec.CompressedData, Sec.DecompressedData);
Sec.CompressedData.Seek(0, soFromBeginning);
Sec.DecompressedData.Seek(0, soFromBeginning);
end;
end;
procedure TDosDatDecompressor.LoadSectionList(SrcStream: TStream; aList: TDosDatSectionList;
DecompressOnTheFly: Boolean = True);
{-------------------------------------------------------------------------------
This is a kind of specialized method to auto split up the file or stream in
it's sections. Mainly to keep the extraction knowledge in this class.
Other classes only need to know that there ARE sections and can use this
method to easily get all data.
Since in these days this dos file sizes are peanuts we can just cache the
whole thing without any problem.
Because it's fast to0, I don't think progress feedback is needed for one
extraction of all sections.
On error the list is cleared.
-------------------------------------------------------------------------------}
{ TODO : put in more checks }
var
Header: TCompressionHeaderRec;
Rd: Integer;
Sec: TDosDatSection;
CopySize: Integer;
CSize, DSize: Integer;
begin
aList.Clear;
SrcStream.Seek(0, soFromBeginning);
repeat
Rd := SrcStream.Read(Header, SizeOf(Header));
if Rd = 0 then
Break;
if Rd <> SizeOf(Header) then
raise Exception.Create('Decompressor Header Error');
CSize := System.Swap(Header.CompressedSize) + (System.Swap(Header.Unused2) shl 16);
CopySize := CSize;
Dec(CSize, 10); // exclude the headersize which is included in this size
DSize := System.Swap(Header.DecompressedSize) + (System.Swap(Header.Unused1) shl 16);
SrcStream.Seek(-SizeOf(Header), soFromCurrent); // go back for copying in section object data
Sec := TDosDatSection.Create;
try
// Sec.fDecompressedSize := Header.DecompressedSize;
// Sec.fCompressedSize := Header.CompressedSize;
Sec.CompressedData.CopyFrom(SrcStream, CopySize);
if DecompressOnTheFly then
begin
Sec.CompressedData.Seek(0, soFromBeginning);
DecompressSection(Sec.CompressedData, Sec.DecompressedData);
Sec.CompressedData.Seek(0, soFromBeginning);
Sec.DecompressedData.Seek(0, soFromBeginning);
end
else begin
Sec.CompressedData.Seek(0, soFromBeginning);
Sec.DecompressedData.Seek(0, soFromBeginning);
end;
except
Sec.Free;
aList.Clear;
raise;
end;
aList.Add(Sec);
until False;
end;
procedure TDosDatDecompressor.LoadSectionListFromFile(
const aFileName: string; aList: TDosDatSectionList;
DecompressOnTheFly: Boolean);
var
F: TFileStream;
begin
F := TFileStream.Create(aFileName, fmOpenRead);
try
LoadSectionList(F, aList, DecompressOnTheFly);
finally
F.Free;
end;
end;
{ TDosDatSection }
constructor TDosDatSection.Create;
begin
inherited;
fCompressedData := TMemoryStream.Create;
fDecompressedData := TMemoryStream.Create;
end;
destructor TDosDatSection.Destroy;
begin
fCompressedData.Free;
fDecompressedData.Free;
inherited;
end;
{ TDosDatSectionList }
function TDosDatSectionList.Add(Item: TDosDatSection): Integer;
begin
Result := inherited Add(Item);
end;
function TDosDatSectionList.GetItem(Index: Integer): TDosDatSection;
begin
Result := inherited Get(Index);
end;
procedure TDosDatSectionList.Insert(Index: Integer; Item: TDosDatSection);
begin
inherited Insert(Index, Item);
end;
procedure TDosDatSectionList.SetItem(Index: Integer;
const Value: TDosDatSection);
begin
inherited Items[Index] := Value;
end;
{ TDosDatCompressor }
procedure TDosDatCompressor.InternalCompress;
{-------------------------------------------------------------------------------
Original code of Mindless
-------------------------------------------------------------------------------}
var
Ref, Len, Raw: Word;
begin
di := 0;
ci := 0;
BitCnt := 8;
Raw := 0;
repeat
//Ref := 0;
Len := 0;
Ref := FindLongRef(Len);
if Ref <> 0 then
begin
EncodeRawChunk(Raw);
PushNextBits(12, Ref - 1);
PushNextBits(8, Len);
PushNextBits(3, 6); // 110b
Inc(di, Len + 1);
end
else begin
Ref := FindRef(4);
if Ref <> 0 then
begin
EncodeRawChunk(Raw);
PushNextBits(10, Ref - 1);
PushNextBits(3, 5); // 101b
Inc(di, 4);
end
else begin
Ref := FindRef(3);
if Ref <> 0 then
begin
EncodeRawChunk(Raw);
PushNextBits(9, Ref - 1);
PushNextBits(3, 4); // 100b
Inc(di, 3);
end
else begin
Ref := FindRef(2);
if Ref <> 0 then
begin
EncodeRawChunk(Raw);
PushNextBits(8, Ref - 1);
PushNextBits(2, 1); // 01b
Inc(di, 2);
end;
end;
end;
end;
if Ref = 0 then
begin
PushNextBits(8, DData^[di]);
Inc(Raw);
if Raw = 264 then
EncodeRawChunk(Raw);
Inc(di);
//deb([di, raw]);
end;
if Assigned(fOnProgress) then
if di mod 8 = 0 then //totally random which says: do not call too often
fOnProgress(di, DSize);
until di > DSize;
EncodeRawChunk(Raw);
end;
function TDosDatCompressor.FindLongRef(var Len: Word): Word;
{-------------------------------------------------------------------------------
Find a chunk of duplicate sourcedata
-------------------------------------------------------------------------------}
{ WOW for the VAR Len}
var
MaxDst, MaxLen, i, L, Ref: word;
begin
MaxLen := 1 shl 8; // 256
MaxDst := 1 shl 12; // 4096
i := di + 1;
Ref := 0;
while i < di + MaxDst do
begin
for L := 0 to MaxLen - 1 do
begin
if (i + L > DSize) then
Break;
if (DData^[di + L] <> DData^[i + L]) then
Break;
if L > Len then
begin
Ref := i - di;
Len := L;
end;
end;
Inc(i);
end;
if Len < 5 then
Ref := 0;
Result := Ref;
end;
function TDosDatCompressor.FindRef(Len: Word): Word;
var
MaxDst, i, L, Ref: Word;
begin
MaxDst := 0; // stupid compiler warning
case Len of
2: MaxDst := 1 shl 8; // 256
3: MaxDst := 1 shl 9; // 512
4: MaxDst := 1 shl 10; // 1024
end;
i := di + 1;
Ref := 0;
while (i < di + MaxDst) and (Ref = 0) and (i + Len < DSize) do
begin
for L := 0 to Len - 1 do
begin
if (DData^[di + L] <> DData^[i + L]) then
Break
else if L = len - 1 then
Ref := i - di;
end;
Inc(i);
end;
Result := Ref;
// if Result <> 0 then deb(['result']);
end;
procedure TDosDatCompressor.EncodeRawChunk(var Len: Word);
{ WOW for the VAR Len}
begin
if Len = 0 then
Exit;
if Len >= 9 then
begin
PushNextBits(8, Len - 9);
PushNextBits(3, 7); // 111b
end
else begin
PushNextBits(3, Len - 1);
PushNextBits(2, 0); // 00b
end;
Len := 0;
end;
procedure TDosDatCompressor.PushNextBits(N, Bits: Word);
begin
repeat
if BitCnt = 0 then
begin
Inc(ci);
if ci > CSize then
begin
CSize := ci;
ReallocMem(CData, CSize + 1);
end;
BitCnt := 8;
end;
CData^[ci] := CData^[ci] shl 1;
CData^[ci] := CData^[ci] or (Bits and 1); // if ci < 5 then deb(['ci,cdata[ci],bitcnt',ci, cdata^[ci],bit8str(cdata^[ci]), bitcnt]);
Bits := Bits shr 1;
Dec(BitCnt);
Dec(n);
until n = 0;
end;
procedure TDosDatCompressor.CompressFile(const aFileName, aDstFile: string);
var
F: TFileStream;
Header: TCompressionHeaderRec;
procedure savetotemp;
var
t: tfilestream;
begin
t := tfilestream.create(adstFile, fmcreate);
try
t.write(header, sizeof(header));
t.write(cdata^, csize + 1);
finally
t.free;
end;
end;
var
i{, rd}: Integer;
begin
F := TFileStream.Create(aFileName, fmOpenRead);
try
FillChar(Header, SizeOf(Header), 0);
DSize := F.Size - 1;
CSize := DSize;
GetMem(DData, DSize + 1);
GetMem(CData, CSize + 1);
FillChar(DData^, DSize + 1, 0);
FillChar(CData^, CSize + 1, 0);
try
{Rd := }F.Read(DData^, DSize + 1);
InternalCompress;
CSize := ci;
ReallocMem(cdata, CSize + 1);
Header.BitCnt := 8 - BitCnt;
Header.CheckSum := 0;
for i := 0 to CSize do
Header.CheckSum := Header.Checksum xor CData^[i];
Header.DecompressedSize := DSize + 1;
Header.CompressedSize := ci + 10 + 1;
{
windlg(['checksum = ' + hexstr(header.checksum),
'decompressed size = ' + i2s(dsize+1),
'compressed size = ' + i2s(ci+1)]); }
// convert little-endian to big-endian
Header.DecompressedSize := system.swap(header.DecompressedSize);
Header.CompressedSize := system.swap(header.CompressedSize);
Savetotemp;
finally
FreeMem(DData);
FreeMem(CData);
CData := nil;
DData := nil;
end;
finally
F.Free;
end;
end;
function TDosDatCompressor.Compress(Src, Dst: TStream): Integer;
var
Header: TCompressionHeaderRec;
NumBytes: Integer;
i: Integer;
begin
//Result := 0;
NumBytes := Src.Size - Src.Position;
FillChar(Header, SizeOf(Header), 0);
DSize := Numbytes - 1;
CSize := DSize;
GetMem(DData, DSize + 1);
GetMem(CData, CSize + 1);
FillChar(DData^, DSize + 1, 0);
FillChar(CData^, CSize + 1, 0);
try
Src.ReadBuffer(DData^, DSize + 1);
InternalCompress;
CSize := ci;
ReallocMem(CData, CSize + 1);
Header.BitCnt := 8 - BitCnt;
Header.CheckSum := 0;
for i := 0 to CSize do
Header.CheckSum := Header.Checksum xor CData^[i];
Header.DecompressedSize := DSize + 1;
Header.CompressedSize := ci + 10 + 1;
{
windlg(['checksum = ' + hexstr(header.checksum),
'decompressed size = ' + i2s(dsize+1),
'compressed size = ' + i2s(ci+1)]); }
// convert little-endian to big-endian
Header.DecompressedSize := System.Swap(Header.DecompressedSize);
Header.CompressedSize := System.Swap(Header.CompressedSize);
Dst.WriteBuffer(Header, COMPRESSIONHEADER_SIZE);
Dst.WriteBuffer(CData^, CSize + 1);
Result := CSize + 1 + COMPRESSIONHEADER_SIZE;
// windlg(['after compress', header.compressedsize, header.decompressedsize]);
//Savetotemp;
finally
FreeMem(DData);
FreeMem(CData);
CData := nil;
DData := nil;
end;
end;
procedure TDosDatCompressor.StoreSection(aList: TDosDatSection;
DstStream: TStream; CompressOnTheFly: Boolean);
begin
//
end;
procedure TDosDatCompressor.StoreSectionList(aList: TDosDatSectionList;
DstStream: TStream; CompressOnTheFly: Boolean = True);
{-------------------------------------------------------------------------------
Write compresseddata of each section item to stream.
-------------------------------------------------------------------------------}
var
i: Integer;
Sec: TDosDatSection;
begin
with aList do
for i := 0 to Count - 1 do
begin
Sec := Items[i];
if CompressOnTheFly then
begin
Sec.DecompressedData.Seek(0, soFromBeginning);
Sec.CompressedData.Clear;
Compress(Sec.DecompressedData, Sec.CompressedData);
end;
Sec.CompressedData.Seek(0, soFromBeginning);
DstStream.CopyFrom(Sec.CompressedData, Sec.CompressedData.Size);
end;
end;
end.
|
{
Copyright (C) 2013-2018 Tim Sinaeve tim.sinaeve@gmail.com
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.
}
unit LogViewer.Messages.Data;
// will be dismissed.
interface
uses
System.Classes,
Spring.Collections,
DDuce.Logger.Interfaces;
type
TLogMessageData = class
private
FMessageType : TLogMessageType;
FTimeStamp : TDateTime;
FText : string;
FData : TStream;
FLevel : Integer;
FIndex : Integer;
FParent : TLogMessageData;
FChildren : IList<TLogMessageData>;
protected
function GetChildren: IList<TLogMessageData>;
public
procedure AfterConstruction; override;
procedure BeforeDestruction; override;
property Index: Integer
read FIndex write FIndex;
property Parent: TLogMessageData
read FParent write FParent;
property Level: Integer
read FLevel write FLevel;
property Data: TStream
read FData;
property MessageType : TLogMessageType
read FMessageType write FMessageType;
property TimeStamp: TDateTime
read FTimeStamp write FTimeStamp;
property Text: string
read FText write FText;
property Children: IList<TLogMessageData>
read GetChildren;
end;
implementation
{$REGION 'construction and destruction'}
procedure TLogMessageData.AfterConstruction;
begin
inherited AfterConstruction;
FData := TMemoryStream.Create;
FChildren := TCollections.CreateObjectList<TLogMessageData>(False);
end;
procedure TLogMessageData.BeforeDestruction;
begin
FData.Free;
FParent := nil;
inherited BeforeDestruction;
end;
{$ENDREGION}
{$REGION 'property access methods'}
function TLogMessageData.GetChildren: IList<TLogMessageData>;
begin
Result := FChildren;
end;
{$ENDREGION}
end.
|
unit UFunctions;
interface
uses IdHashMessageDigest, FireDAC.Comp.Client;
function fcm_GetStringHashAsString(str: String):String;
function fCheckRequirements(sTableName, sColumnName, sParams, sParamsValue: String):Boolean;
function fCheckPassLength(sPassword: String):Boolean;
function fCheckUsername(sUsername: String):Boolean;
implementation
uses UDM;
function fcm_GetStringHashAsString(str: String):String;
{ ****************************************************************************
Source:
https://forums.embarcadero.com/message.jspa?messageID=660607#660607
**************************************************************************** }
var
MD5: TIdHashMessageDigest5;
begin
MD5 := TIdHashMessageDigest5.Create();
Result := MD5.HashStringAsHex(str);
MD5.Free;
end;
function fCheckRequirementsFromTable(sTableName, sColumnName, sParams, sParamsValue: String):Boolean;
var qheckRequirementsFromTable: TFDQuery;
begin
qheckRequirementsFromTable := TFDQuery.Create(nil);
try
with qheckRequirementsFromTable do
begin
Connection := DM.DbduitkuConnection;
Close;
SQL.Text := 'SELECT '+sColumnName+' FROM '+sTableName+' WHERE '+
sColumnName+'=:'+sParams+';';
Params.ParamByName(sParams).Value := sParamsValue;
Open;
if RecordCount > 0 then
Result := True
else
Result := False;
end;
finally
qheckRequirementsFromTable.Free;
end;
end;
function fCheckPassLength(sPassword: String):Boolean;
begin
if Length(sPassword) >= 8 then
Result := True
else
Result := False;
end;
function fCheckUsername(sUsername: String):Boolean;
var
vGender: Integer;
qSaveUsers: TFDQuery;
begin
qSaveUsers := TFDQuery.Create(nil);
try
with qSaveUsers do
begin
Connection := DM.DbduitkuConnection;
Close;
SQL.Text := 'SELECT * FROM m_users WHERE username=:username';
Params.ParamByName('username').Value := sUsername;
Open;
if RecordCount > 0 then
Result := True
else
Result := False;
end;
finally
qSaveUsers.Free;
end;
end;
end.
|
{*********************************************************************}
{ TInspectorBar inplace edit controls }
{ for Delphi & C++Builder }
{ }
{ written by }
{ TMS Software }
{ copyright © 2001 - 2013 }
{ Email : info@tmssoftware.com }
{ Web : http://www.tmssoftware.com }
{ }
{ The source code is given as is. The author is not responsible }
{ for any possible damage done due to the use of this code. }
{ The component can be freely used in any application. The source }
{ code remains property of the author and may not be distributed }
{ freely as such. }
{*********************************************************************}
unit InspEdits;
{$I TMSDEFS.INC}
interface
{$R InspEdits.Res}
uses
Windows, Messages, Classes, Forms, Controls, Graphics, StdCtrls, SysUtils,
InspXPVS, Buttons, ExtCtrls, Mask, ComCtrls, Dialogs
{$IFDEF DELPHI_UNICODE}
, Character
{$ENDIF}
{$IFDEF DELPHIXE3_LVL}
, System.UITypes
{$ENDIF}
;
type
TWinCtrl = class(TWinControl);
TAdvSpeedButton = class(TSpeedButton)
private
FIsWinXP: Boolean;
FFlat: Boolean;
FHot: Boolean;
procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
procedure CMMouseEnter(var Message: TMessage); message CM_MOUSEENTER;
function DoVisualStyles: Boolean;
protected
procedure Paint; override;
public
property Hot: Boolean read FHot write FHot;
published
property IsWinXP: Boolean read FIsWinXP write FIsWinXP;
property Flat: Boolean read FFlat write FFlat;
end;
TInspCustomCombo = class(TCustomComboBox)
private
FAutoFocus: boolean;
FFlat: Boolean;
FEtched: Boolean;
FOldColor: TColor;
FOldParentColor: Boolean;
FButtonWidth: Integer;
FFocusBorder: Boolean;
FMouseInControl: Boolean;
FDropWidth: integer;
FIsWinXP: Boolean;
FBkColor: TColor;
procedure SetEtched(const Value: Boolean);
procedure SetFlat(const Value: Boolean);
procedure SetButtonWidth(const Value: Integer);
procedure DrawButtonBorder(DC:HDC);
procedure DrawControlBorder(DC:HDC);
procedure DrawBorders;
function Is3DBorderControl: Boolean;
function Is3DBorderButton: Boolean;
procedure CMEnter(var Message: TCMEnter); message CM_ENTER;
procedure CMExit(var Message: TCMExit); message CM_EXIT;
procedure CMMouseEnter(var Message: TMessage); message CM_MOUSEENTER;
procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
procedure CMEnabledChanged(var Msg: TMessage); message CM_ENABLEDCHANGED;
procedure CNCommand (var Message: TWMCommand); message CN_COMMAND;
procedure WMPaint(var Message: TWMPaint); message WM_PAINT;
procedure WMNCPaint (var Message: TMessage); message WM_NCPAINT;
procedure SetDropWidth(const Value: integer);
function DoVisualStyles: Boolean;
protected
property BkColor: TColor read FBkColor write FBkColor;
property ButtonWidth: integer read FButtonWidth write SetButtonWidth;
property Flat: Boolean read FFlat write SetFlat;
property Etched: Boolean read FEtched write SetEtched;
property FocusBorder: Boolean read FFocusBorder write FFocusBorder;
property AutoFocus: Boolean read FAutoFocus write FAutoFocus;
property DropWidth: integer read fDropWidth write SetDropWidth;
property IsWinXP: Boolean read FIsWinXP write FIsWinXP;
public
constructor Create(AOwner: TComponent); override;
end;
TInspComboBox = class(TInspCustomCombo)
published
property AutoFocus;
property ButtonWidth;
property Style;
property Flat;
property Etched;
property FocusBorder;
property Color;
property Ctl3D;
property DragCursor;
property DragMode;
property DropDownCount;
property DropWidth;
property Enabled;
property Font;
{$IFNDEF DELPHI2_LVL}
property ImeMode;
property ImeName;
{$ENDIF}
property ItemHeight;
property Items;
property MaxLength;
property ParentColor;
property ParentCtl3D;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property Sorted;
property TabOrder;
property TabStop;
property Text;
property Visible;
property OnChange;
property OnClick;
{$IFDEF DELPHI6_LVL}
property OnCloseUp;
{$ENDIF}
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnDrawItem;
property OnDropDown;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMeasureItem;
property OnStartDrag;
property Anchors;
property BiDiMode;
property Constraints;
property DragKind;
property ParentBiDiMode;
property OnEndDock;
property OnStartDock;
end;
TNumGlyphs = Buttons.TNumGlyphs;
TAdvTimerSpeedButton = class;
{ TInspSpinButton }
TSpinDirection = (spVertical,spHorizontal);
TInspSpinButton = class (TWinControl)
private
FUpButton: TAdvTimerSpeedButton;
FDownButton: TAdvTimerSpeedButton;
FFocusedButton: TAdvTimerSpeedButton;
FFocusControl: TWinControl;
FOnUpClick: TNotifyEvent;
FOnDownClick: TNotifyEvent;
FDirection: TSpinDirection;
FIsWinXP: Boolean;
//FHasUpRes,FHasDownRes:boolean;
function CreateButton: TAdvTimerSpeedButton;
function GetUpGlyph: TBitmap;
function GetDownGlyph: TBitmap;
procedure SetUpGlyph(Value: TBitmap);
procedure SetDownGlyph(Value: TBitmap);
function GetUpNumGlyphs: TNumGlyphs;
function GetDownNumGlyphs: TNumGlyphs;
procedure SetUpNumGlyphs(Value: TNumGlyphs);
procedure SetDownNumGlyphs(Value: TNumGlyphs);
procedure BtnClick(Sender: TObject);
procedure BtnMouseDown (Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure SetFocusBtn (Btn: TAdvTimerSpeedButton);
procedure SetDirection(const Value: TSpinDirection);
procedure AdjustSize (var W, H: Integer); reintroduce;
procedure WMSize(var Message: TWMSize); message WM_SIZE;
procedure WMSetFocus(var Message: TWMSetFocus); message WM_SETFOCUS;
procedure WMKillFocus(var Message: TWMKillFocus); message WM_KILLFOCUS;
procedure WMGetDlgCode(var Message: TWMGetDlgCode); message WM_GETDLGCODE;
procedure SetIsWinXP(const Value: Boolean);
protected
procedure Loaded; override;
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
property IsWinXP: Boolean read FIsWinXP write SetIsWinXP;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override;
published
property Align;
property Anchors;
property Constraints;
property Ctl3D;
property Direction: TSpinDirection read fDirection write SetDirection;
property DownGlyph: TBitmap read GetDownGlyph write SetDownGlyph;
property DownNumGlyphs: TNumGlyphs read GetDownNumGlyphs write SetDownNumGlyphs default 1;
property DragCursor;
property DragKind;
property DragMode;
property Enabled;
property FocusControl: TWinControl read FFocusControl write FFocusControl;
property ParentCtl3D;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property TabOrder;
property TabStop;
property UpGlyph: TBitmap read GetUpGlyph write SetUpGlyph;
property UpNumGlyphs: TNumGlyphs read GetUpNumGlyphs write SetUpNumGlyphs default 1;
property Visible;
property OnDownClick: TNotifyEvent read FOnDownClick write FOnDownClick;
property OnDragDrop;
property OnDragOver;
property OnEndDock;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnStartDock;
property OnStartDrag;
property OnUpClick: TNotifyEvent read FOnUpClick write FOnUpClick;
end;
{ TInspSpinEdit }
TInspSpinType = (sptNormal,sptFloat,sptDate,sptTime);
TInspSpinEdit = class(TCustomMaskEdit)
private
FMinValue: LongInt;
FMaxValue: LongInt;
FMinFloatValue: double;
FMaxFloatValue: double;
FMinDateValue: TDatetime;
FMaxDateValue: TDatetime;
FDateValue: TDatetime;
FTimeValue: TDatetime;
FIncrement: LongInt;
FIncrementFloat : double;
FButton: TInspSpinButton;
FEditorEnabled: Boolean;
FDirection: TSpinDirection;
FSpinType:TInspSpinType;
FPrecision: integer;
FReturnIsTab: boolean;
FIsWinXP: Boolean;
FOnSpinUp: TNotifyEvent;
FOnSpinDown: TNotifyEvent;
FOnSpinChange: TNotifyEvent;
FSpinFlat : Boolean;
FSpinTransparent : Boolean;
function GetMinHeight: Integer;
function GetValue: LongInt;
function CheckValue (NewValue: LongInt): LongInt;
procedure SetValue (NewValue: LongInt);
function GetFloatValue: double;
function CheckFloatValue (NewValue: double): double;
function CheckDateValue (NewValue: TDatetime): TDatetime;
procedure SetFloatValue (NewValue: double);
procedure SetEditorEnabled(NewValue:boolean);
procedure SetDirection(const Value: TSpinDirection);
procedure SetPrecision(const Value: integer);
procedure SetSpinType(const Value: TInspSpinType);
function GetTimeValue: TDatetime;
procedure SetTimeValue(const Value: TDatetime);
function GetDateValue: tdatetime;
procedure SetDateValue(const Value: TDatetime);
procedure SetSpinFlat(const Value : boolean);
procedure SetSpinTransparent(const value : boolean);
procedure WMSize(var Message: TWMSize); message WM_SIZE;
procedure CMEnter(var Message: TCMGotFocus); message CM_ENTER;
procedure CMExit(var Message: TCMExit); message CM_EXIT;
procedure WMPaste(var Message: TWMPaste); message WM_PASTE;
procedure WMCut(var Message: TWMCut); message WM_CUT;
procedure WMKeyDown(var Message: TWMKeyDown); message WM_KEYDOWN;
procedure SetIsWinXP(const Value: Boolean);
protected
function IsValidChar(var Key: Char): Boolean; virtual;
procedure UpClick (Sender: TObject); virtual;
procedure DownClick (Sender: TObject); virtual;
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
procedure KeyPress(var Key: Char); override;
procedure CreateParams(var Params: TCreateParams); override;
procedure CreateWnd; override;
procedure Loaded; override;
property IsWinXP: Boolean read FIsWinXP write SetIsWinXP;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
property Button: TInspSpinButton read FButton;
procedure SetEditRect;
procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
published
property Direction : TSpinDirection read FDirection write SetDirection;
property ReturnIsTab: boolean read FReturnIsTab write fReturnIsTab;
property Precision: integer read FPrecision write SetPrecision;
property SpinType: TInspSpinType read FSpinType write SetSpinType;
property Value: LongInt read GetValue write SetValue;
property FloatValue: double read GetFloatValue write SetFloatValue;
property TimeValue: TDatetime read GetTimeValue write SetTimeValue;
property DateValue: TDatetime read GetDateValue write SetDateValue;
property SpinFlat : boolean read FSpinFlat write SetSpinFlat;
property SpinTransparent : boolean read FSpinTransparent write SetSpinTransparent;
property Anchors;
property AutoSelect;
property AutoSize;
property BorderStyle;
property Color;
property Constraints;
property Ctl3D;
property DragCursor;
property DragMode;
property EditorEnabled: Boolean read FEditorEnabled write SetEditorEnabled default True;
property Enabled;
property Font;
property Increment: LongInt read FIncrement write FIncrement default 1;
property IncrementFloat: double read FIncrementFloat write FIncrementFloat;
property MaxLength;
property MaxValue: LongInt read FMaxValue write FMaxValue;
property MinValue: LongInt read FMinValue write FMinValue;
property MinFloatValue: double read fMinFloatValue write fMinFloatValue;
property MaxFloatValue: double read fMaxFloatValue write fMaxFloatValue;
property MinDateValue: TDatetime read fMinDateValue write fMinDateValue;
property MaxDateValue: TDatetime read fMaxDateValue write fMaxDateValue;
property ParentColor;
property ParentCtl3D;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property ReadOnly;
property ShowHint;
property TabOrder;
property TabStop;
property Visible;
property OnChange;
property OnClick;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnStartDrag;
property OnSpinUp: TNotifyEvent read FOnSpinUp write FOnSpinUp;
property OnSpinDown: TNotifyEvent read FOnSpinDown write FOnSpinDown;
property OnSpinChange: TNotifyEvent read FOnSpinChange write FOnSpinChange;
end;
TAdvMaskSpinEdit = class(TInspSpinEdit)
published
property EditMask;
end;
{ TAdvTimerSpeedButton }
TTimeBtnState = set of (tbFocusRect, tbAllowTimer);
TButtonDirection = (bdLeft,bdRight,bdUp,bdDown);
TAdvTimerSpeedButton = class(TSpeedButton)
private
FRepeatTimer: TTimer;
FTimeBtnState: TTimeBtnState;
FButtonDirection:TButtonDirection;
FIsWinXP: Boolean;
procedure TimerExpired(Sender: TObject);
function DoVisualStyles: Boolean;
protected
procedure Paint; override;
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
property IsWinXP: Boolean read FIsWinXP write FIsWinXP;
public
destructor Destroy; override;
property TimeBtnState: TTimeBtnState read FTimeBtnState write FTimeBtnState;
property ButtonDirection: TButtonDirection read FButtonDirection write FButtonDirection;
end;
TInspEditButton = class (TWinControl)
private
FButton: TAdvSpeedButton;
FFocusControl: TWinControl;
FOnClick: TNotifyEvent;
FFlat: Boolean;
FIsWinXP: Boolean;
function CreateButton: TAdvSpeedButton;
function GetGlyph: TBitmap;
procedure SetGlyph(Value: TBitmap);
function GetNumGlyphs: TNumGlyphs;
procedure SetNumGlyphs(Value: TNumGlyphs);
procedure SetCaption(value:string);
function GetCaption:string;
procedure BtnClick(Sender: TObject);
procedure BtnMouseDown (Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure AdjustSize (var W, H: Integer); reintroduce;
procedure WMSize(var Message: TWMSize); message WM_SIZE;
procedure SetFlat(const Value: Boolean);
procedure SetIsWinXP(const Value: Boolean);
protected
procedure Loaded; override;
procedure Notification(AComponent: TComponent;
Operation: TOperation); override;
public
constructor Create(AOwner: TComponent); override;
procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override;
published
property Align;
property Ctl3D;
property Glyph: TBitmap read GetGlyph write SetGlyph;
property ButtonCaption:string read GetCaption write SetCaption;
property NumGlyphs: TNumGlyphs read GetNumGlyphs write SetNumGlyphs default 1;
property DragCursor;
property DragMode;
property Enabled;
property FocusControl: TWinControl read FFocusControl write FFocusControl;
property Flat: Boolean read FFlat write SetFlat;
property IsWinXP: Boolean read FIsWinXP write SetIsWinXP;
property ParentCtl3D;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property TabOrder;
property TabStop;
property Visible;
property OnDragDrop;
property OnDragOver;
property OnEndDrag;
property OnEnter;
property OnExit;
{$IFDEF WIN32}
property OnStartDrag;
{$ENDIF}
property OnClick: TNotifyEvent read FOnClick write FOnClick;
end;
{ TInspEditBtn }
TInspEditBtn = class(TCustomEdit)
private
FUnitSize : integer;
FRightAlign: Boolean;
FButton: TInspEditButton;
FEditorEnabled: Boolean;
FOnClickBtn:TNotifyEvent;
FButtonWidth: Integer;
FIsWinXP: Boolean;
//FGlyph: TBitmap;
function GetMinHeight: Integer;
procedure SetGlyph(value:tBitmap);
function GetGlyph:TBitmap;
procedure SetCaption(value:string);
function GetCaption:string;
procedure SetRightAlign(value : boolean);
procedure WMSize(var Message: TWMSize); message WM_SIZE;
procedure CMEnter(var Message: TCMGotFocus); message CM_ENTER;
procedure CMExit(var Message: TCMExit); message CM_EXIT;
procedure WMPaste(var Message: TWMPaste); message WM_PASTE;
procedure WMCut(var Message: TWMCut); message WM_CUT;
procedure WMPaint(var Msg: TWMPAINT); message WM_PAINT;
procedure WMChar(var Message: TWMChar); message WM_CHAR;
procedure SetButtonWidth(const Value: Integer);
procedure SetIsWinXP(const Value: Boolean);
protected
procedure BtnClick(Sender: TObject); virtual;
procedure BtnExit(Sender: TObject); virtual;
procedure CreateParams(var Params: TCreateParams); override;
procedure CreateWnd; override;
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
procedure KeyPress(var Key: Char); override;
procedure DoEnter; override;
procedure ResizeControl;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
property Button: TInspEditButton read FButton;
procedure SetEditRect;
published
property AutoSelect;
property AutoSize;
property BorderStyle;
property ButtonWidth: Integer read FButtonWidth write SetButtonWidth;
property Color;
property Ctl3D;
property DragCursor;
property DragMode;
property EditorEnabled: Boolean read FEditorEnabled write FEditorEnabled default True;
property Enabled;
property Font;
property Glyph: TBitmap read GetGlyph write SetGlyph;
property IsWinXP: Boolean read FIsWinXP write SetIsWinXP;
property ButtonCaption:string read GetCaption write SetCaption;
property MaxLength;
property ParentColor;
property ParentCtl3D;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property ReadOnly;
property RightAlign:boolean read fRightAlign write SetRightAlign;
property ShowHint;
property TabOrder;
property TabStop;
property Text;
property Visible;
property Height;
property Width;
property OnChange;
property OnClick;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
{$IFDEF WIN32}
property OnStartDrag;
{$ENDIF}
property OnClickBtn: TNotifyEvent read FOnClickBtn write FOnClickBtn;
end;
TInspDateTimePicker = class(TDateTimePicker)
private
procedure WMNCPaint (var Message: TMessage); message WM_NCPAINT;
protected
published
public
end;
TInspColorComboBox = class(TInspComboBox)
private
FCustomColor: TColor;
function GetColorValue: TColor;
procedure SetColorValue(const Value: TColor);
protected
procedure DrawItem(Index: Integer; Rect: TRect; State: TOwnerDrawState); override;
public
published
property IsWinXP;
property BkColor;
property ColorValue: TColor read GetColorValue write SetColorValue;
property CustomColor: TColor read FCustomColor write FCustomColor;
end;
implementation
const
InitRepeatPause = 400; { pause before repeat timer (ms) }
RepeatPause = 100; { pause before hint window displays (ms)}
{$I DELPHIXE.INC}
function IsNumChar(ch: char): boolean;
begin
{$IFNDEF DELPHIXE4_LVL}
{$IFNDEF DELPHI_UNICODE}
Result := (ch in ['0'..'9']);
{$ENDIF}
{$IFDEF DELPHI_UNICODE}
Result := Character.IsNumber(ch);
{$ENDIF}
{$ENDIF}
{$IFDEF DELPHIXE4_LVL}
Result := ch.IsNumber;
{$ENDIF}
end;
{ TInspCustomCombo }
constructor TInspCustomCombo.Create(AOwner: TComponent);
begin
inherited;
FButtonWidth := GetSystemMetrics(SM_CXVSCROLL) + 2;
FOldColor := inherited Color;
FOldParentColor := inherited ParentColor;
FFlat := True;
FMouseInControl := False;
end;
procedure TInspCustomCombo.SetButtonWidth(const Value: integer);
begin
if (value < 14) or (value > 32) then Exit;
FButtonWidth := Value;
Invalidate;
end;
procedure TInspCustomCombo.SetFlat(const Value: Boolean);
begin
if Value<>FFlat then
begin
FFlat := Value;
Ctl3D := not Value;
Invalidate;
end;
end;
procedure TInspCustomCombo.SetEtched(const Value: Boolean);
begin
if Value <> FEtched then
begin
FEtched := Value;
Invalidate;
end;
end;
procedure TInspCustomCombo.CMEnter(var Message: TCMEnter);
begin
inherited;
if not (csDesigning in ComponentState) then
DrawBorders;
end;
procedure TInspCustomCombo.CMExit(var Message: TCMExit);
begin
inherited;
if not (csDesigning in ComponentState) then
DrawBorders;
end;
procedure TInspCustomCombo.CMMouseEnter(var Message: TMessage);
begin
inherited;
if not FMouseInControl and Enabled then
begin
FMouseInControl := True;
DrawBorders;
end;
if FAutoFocus then
Self.SetFocus;
end;
procedure TInspCustomCombo.CMMouseLeave(var Message: TMessage);
begin
inherited;
if FMouseInControl and Enabled then
begin
FMouseInControl := False;
DrawBorders;
end;
end;
procedure TInspCustomCombo.CMEnabledChanged(var Msg: TMessage);
begin
if FFlat then
begin
if Enabled then
begin
inherited ParentColor := FOldParentColor;
inherited Color := FOldColor;
end
else
begin
FOldParentColor := inherited Parentcolor;
FOldColor := inherited Color;
inherited ParentColor := True;
end;
end;
inherited;
end;
procedure TInspCustomCombo.WMNCPaint(var Message: TMessage);
begin
inherited;
if FFlat then
DrawBorders;
end;
function IsMouseButtonDown:Boolean;
{
Returns a "True" if a Mouse button happens to be down.
}
begin
{Note: Key state is read twice because the first time you read it, you
learn
if the bittpm has been pressed ever. The second time you read it you
learn if
the button is currently pressed.}
if ((GetAsyncKeyState(VK_RBUTTON)and $8000)=0) and
((GetAsyncKeyState(VK_LBUTTON)and $8000)=0) then
begin
{Mouse buttons are up}
Result:=False;
end
else
begin
{Mouse buttons are up}
Result:=True;
end;
end;
procedure TInspCustomCombo.WMPaint(var Message: TWMPaint);
var
DC: HDC;
PS: TPaintStruct;
procedure DrawButton;
var
ARect: TRect;
htheme: THandle;
begin
GetWindowRect(Handle, ARect);
OffsetRect(ARect, -ARect.Left, -ARect.Top);
Inc(ARect.Left, ClientWidth - FButtonWidth);
InflateRect(ARect, -1, -1);
ARect.Bottom := ARect.Top + 17;
if DoVisualStyles then
begin
htheme := OpenThemeData(Handle,'combobox');
if IsMouseButtonDown then
DrawThemeBackground(htheme,DC,CP_DROPDOWNBUTTON,CBXS_PRESSED,@ARect,nil)
else
DrawThemeBackground(htheme,DC,CP_DROPDOWNBUTTON,CBXS_NORMAL,@ARect,nil);
CloseThemeData(htheme);
end
else
DrawFrameControl(DC, ARect, DFC_SCROLL, DFCS_SCROLLCOMBOBOX or DFCS_FLAT );
ExcludeClipRect(DC, ClientWidth - FButtonWidth - 4 , 0, ClientWidth + 2, ClientHeight);
end;
begin
if not FFlat then
begin
inherited;
Exit;
end;
if Message.DC = 0 then
DC := BeginPaint(Handle, PS)
else
DC := Message.DC;
try
if (Style <> csSimple) and not DoVisualStyles then
begin
FillRect(DC, ClientRect, Brush.Handle);
DrawButton;
end;
PaintWindow(DC);
finally
if Message.DC = 0 then
EndPaint(Handle, PS);
end;
if DoVisualStyles then
inherited;
DrawBorders;
end;
function TInspCustomCombo.Is3DBorderControl: Boolean;
begin
if csDesigning in ComponentState then
Result := False
else
Result := FMouseInControl or (Screen.ActiveControl = Self);
Result := Result and FFocusBorder;
end;
function TInspCustomCombo.Is3DBorderButton: Boolean;
begin
if csDesigning in ComponentState then
Result := Enabled
else
Result := FMouseInControl or (Screen.ActiveControl = Self);
end;
procedure TInspCustomCombo.DrawButtonBorder(DC: HDC);
const
Flags: array[Boolean] of Integer = (0, BF_FLAT);
Edge: array[Boolean] of Integer = (EDGE_RAISED,EDGE_ETCHED);
var
ARect: TRect;
BtnFaceBrush: HBRUSH;
begin
ExcludeClipRect(DC, ClientWidth - FButtonWidth + 4, 4, ClientWidth - 4, ClientHeight - 4);
GetWindowRect(Handle, ARect);
OffsetRect(ARect, -ARect.Left, -ARect.Top);
Inc(ARect.Left, ClientWidth - FButtonWidth - 2);
InflateRect(ARect, -2, -2);
if Is3DBorderButton then
DrawEdge(DC, ARect, Edge[Etched], BF_RECT or Flags[DroppedDown])
else
begin
BtnFaceBrush := CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
InflateRect(ARect, 0, -1);
ARect.Right := ARect.Right - 1;
FillRect(DC, ARect, BtnFaceBrush);
DeleteObject(BtnFaceBrush);
end;
ExcludeClipRect(DC, ARect.Left, ARect.Top, ARect.Right, ARect.Bottom);
end;
procedure TInspCustomCombo.DrawControlBorder(DC: HDC);
var
ARect:TRect;
BtnFaceBrush, WindowBrush: HBRUSH;
begin
if Is3DBorderControl then
BtnFaceBrush := CreateSolidBrush(GetSysColor(COLOR_BTNFACE))
else
BtnFaceBrush := CreateSolidBrush(ColorToRGB(FBkColor));
WindowBrush := CreateSolidBrush(ColorToRGB(Color));
try
GetWindowRect(Handle, ARect);
OffsetRect(ARect, -ARect.Left, -ARect.Top);
if Is3DBorderControl then
begin
DrawEdge(DC, ARect, BDR_SUNKENOUTER, BF_RECT or BF_ADJUST);
FrameRect(DC, ARect, BtnFaceBrush);
InflateRect(ARect, -1, -1);
FrameRect(DC, ARect, WindowBrush);
end
else
begin
FrameRect(DC, ARect, BtnFaceBrush);
InflateRect(ARect, -1, -1);
FrameRect(DC, ARect, BtnFaceBrush);
InflateRect(ARect, -1, -1);
FrameRect(DC, ARect, WindowBrush);
end;
finally
DeleteObject(WindowBrush);
DeleteObject(BtnFaceBrush);
end;
end;
procedure TInspCustomCombo.DrawBorders;
var
DC: HDC;
begin
if not FFlat then Exit;
DC := GetWindowDC(Handle);
try
DrawControlBorder(DC);
if (Style <> csSimple) and not DoVisualStyles then
DrawButtonBorder(DC);
finally
ReleaseDC(Handle,DC);
end;
end;
procedure TInspCustomCombo.CNCommand(var Message: TWMCommand);
var
r:TRect;
begin
inherited;
if Message.NotifyCode in [CBN_CLOSEUP,CBN_DROPDOWN] then
begin
r := GetClientRect;
r.left := r.Right - FButtonWidth;
InvalidateRect(Handle,@r,FALSE);
end;
end;
procedure TInspCustomCombo.SetDropWidth(const Value: integer);
begin
FDropWidth := Value;
if value > 0 then
SendMessage(self.Handle,CB_SETDROPPEDWIDTH,FDropWidth,0);
end;
function PosFrom(sub,s:string;n:integer):integer;
begin
Delete(s,1,n);
Result := Pos(sub,s);
if Result > 0 then
Result := Result + n;
end;
function IncYear(d:tdatetime;n:integer):tdatetime;
var
da,mo,ye:word;
begin
DecodeDate(d,ye,mo,da);
ye := ye + n;
Result := EncodeDate(ye,mo,da);
end;
function TInspCustomCombo.DoVisualStyles: Boolean;
begin
if FIsWinXP then
Result := IsThemeActive
else
Result := False;
end;
{ TInspSpinButton }
constructor TInspSpinButton.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
ControlStyle := ControlStyle - [csAcceptsControls, csSetCaption] +
[csFramed, csOpaque];
FUpButton := CreateButton;
FDownButton := CreateButton;
UpGlyph := nil;
DownGlyph := nil;
FUpButton.ButtonDirection:=bdUp;
FDownButton.ButtonDirection:=bdDown;
Width := 15;
Height := 25;
FFocusedButton := FUpButton;
end;
destructor TInspSpinButton.Destroy;
begin
inherited;
end;
function TInspSpinButton.CreateButton: TAdvTimerSpeedButton;
begin
Result := TAdvTimerSpeedButton.Create(Self);
Result.OnClick := BtnClick;
Result.OnMouseDown := BtnMouseDown;
Result.Visible := True;
Result.Enabled := True;
Result.TimeBtnState := [tbAllowTimer];
Result.Parent := Self;
end;
procedure TInspSpinButton.Notification(AComponent: TComponent;
Operation: TOperation);
begin
inherited Notification(AComponent, Operation);
if (Operation = opRemove) and (AComponent = FFocusControl) then
FFocusControl := nil;
end;
procedure TInspSpinButton.AdjustSize (var W, H: Integer);
begin
if (FUpButton = nil) or (csLoading in ComponentState) then Exit;
if FDirection = spVertical then
begin
if W < 15 then W := 15;
FUpButton.SetBounds (0, 0, W, H div 2);
FDownButton.SetBounds (0, FUpButton.Height , W, H - FUpButton.Height -1);
end
else
begin
if W < 20 then W := 20;
FDownButton.SetBounds (0, 0, W div 2, H );
FUpButton.SetBounds ((W div 2)+1, 0 , W div 2, H );
end;
end;
procedure TInspSpinButton.SetBounds(ALeft, ATop, AWidth, AHeight: Integer);
var
W, H: Integer;
begin
W := AWidth;
H := AHeight;
AdjustSize (W, H);
inherited SetBounds (ALeft, ATop, W, H);
end;
procedure TInspSpinButton.WMSize(var Message: TWMSize);
var
W, H: Integer;
begin
inherited;
{ check for minimum size }
W := Width;
H := Height;
AdjustSize (W, H);
if (W <> Width) or (H <> Height) then
inherited SetBounds(Left, Top, W, H);
Message.Result := 0;
end;
procedure TInspSpinButton.WMSetFocus(var Message: TWMSetFocus);
begin
FFocusedButton.TimeBtnState := FFocusedButton.TimeBtnState + [tbFocusRect];
FFocusedButton.Invalidate;
end;
procedure TInspSpinButton.WMKillFocus(var Message: TWMKillFocus);
begin
FFocusedButton.TimeBtnState := FFocusedButton.TimeBtnState - [tbFocusRect];
FFocusedButton.Invalidate;
end;
procedure TInspSpinButton.KeyDown(var Key: Word; Shift: TShiftState);
begin
inherited;
case Key of
VK_UP:
begin
SetFocusBtn (FUpButton);
FUpButton.Click;
end;
VK_DOWN:
begin
SetFocusBtn (FDownButton);
FDownButton.Click;
end;
VK_SPACE:
FFocusedButton.Click;
end;
end;
procedure TInspSpinButton.BtnMouseDown (Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if Button = mbLeft then
begin
SetFocusBtn (TAdvTimerSpeedButton (Sender));
if (FFocusControl <> nil) and FFocusControl.TabStop and
FFocusControl.CanFocus and (GetFocus <> FFocusControl.Handle) then
FFocusControl.SetFocus
else if TabStop and (GetFocus <> Handle) and CanFocus then
SetFocus;
end;
end;
procedure TInspSpinButton.BtnClick(Sender: TObject);
begin
if Sender = FUpButton then
begin
if Assigned(FOnUpClick) then FOnUpClick(Self);
end
else
if Assigned(FOnDownClick) then FOnDownClick(Self);
end;
procedure TInspSpinButton.SetDirection(const Value:TSpinDirection);
begin
if value <> FDirection then
begin
FDirection := Value;
RecreateWnd;
if fdirection = spVertical then
begin
Width := 15;
FUpButton.FButtonDirection := bdUp;
FDownButton.FButtonDirection := bdDown;
end
else
begin
Width := 20;
FUpButton.FButtonDirection:=bdRight;
FDownButton.FButtonDirection:=bdLeft;
end;
end;
end;
procedure TInspSpinButton.SetFocusBtn (Btn: TAdvTimerSpeedButton);
begin
if TabStop and CanFocus and (Btn <> FFocusedButton) then
begin
FFocusedButton.TimeBtnState := FFocusedButton.TimeBtnState - [tbFocusRect];
FFocusedButton := Btn;
if (GetFocus = Handle) then
begin
FFocusedButton.TimeBtnState := FFocusedButton.TimeBtnState + [tbFocusRect];
Invalidate;
end;
end;
end;
procedure TInspSpinButton.WMGetDlgCode(var Message: TWMGetDlgCode);
begin
Message.Result := DLGC_WANTARROWS;
end;
procedure TInspSpinButton.Loaded;
var
W, H: Integer;
begin
inherited Loaded;
W := Width;
H := Height;
AdjustSize (W, H);
if (W <> Width) or (H <> Height) then
inherited SetBounds (Left, Top, W, H);
end;
function TInspSpinButton.GetUpGlyph: TBitmap;
begin
Result := FUpButton.Glyph;
end;
procedure TInspSpinButton.SetUpGlyph(Value: TBitmap);
begin
if Value <> nil then
begin
FUpButton.Glyph := Value
end
else
begin
FUpButton.Glyph.LoadFromResourceName(hinstance,'InspSpinUp');
FUpButton.NumGlyphs := 1;
FUpButton.Invalidate;
end;
end;
function TInspSpinButton.GetUpNumGlyphs: TNumGlyphs;
begin
Result := FUpButton.NumGlyphs;
end;
procedure TInspSpinButton.SetUpNumGlyphs(Value: TNumGlyphs);
begin
FUpButton.NumGlyphs := Value;
end;
function TInspSpinButton.GetDownGlyph: TBitmap;
begin
Result := FDownButton.Glyph;
end;
procedure TInspSpinButton.SetDownGlyph(Value: TBitmap);
begin
if Value <> nil then
FDownButton.Glyph := Value
else
begin
FDownButton.Glyph.LoadFromResourceName(HInstance, 'InspSpinDown');
FUpButton.NumGlyphs := 1;
FDownButton.Invalidate;
end;
end;
function TInspSpinButton.GetDownNumGlyphs: TNumGlyphs;
begin
Result := FDownButton.NumGlyphs;
end;
procedure TInspSpinButton.SetDownNumGlyphs(Value: TNumGlyphs);
begin
FDownButton.NumGlyphs := Value;
end;
procedure TInspSpinButton.SetIsWinXP(const Value: Boolean);
begin
FIsWinXP := Value;
FDownButton.IsWinXP := FIsWinXP;
FFocusedButton.IsWinXP := FIsWinXP;
end;
{ TInspSpinEdit }
constructor TInspSpinEdit.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FButton := TInspSpinButton.Create (Self);
FButton.Width := 17;
FButton.Height := 17;
FButton.Visible := True;
FButton.Parent := Self;
FButton.FocusControl := Self;
FButton.OnUpClick := UpClick;
FButton.OnDownClick := DownClick;
Text := '0';
ControlStyle := ControlStyle - [csSetCaption];
FIncrement := 1;
FEditorEnabled := True;
FMinFloatValue:=0;
FMinValue:=0;
FMaxFloatValue:=100;
FMaxValue:=100;
end;
destructor TInspSpinEdit.Destroy;
begin
FButton := nil;
inherited Destroy;
end;
procedure TInspSpinEdit.Loaded;
begin
inherited;
case fSpinType of
sptDate:self.Text := DateToStr(FDateValue);
sptTime:self.Text := TimeToStr(FTimeValue);
end;
SetSpinType(fSpinType);
end;
procedure TInspSpinEdit.GetChildren(Proc: TGetChildProc; Root: TComponent);
begin
end;
procedure TInspSpinEdit.WMKeyDown(var Message: TWMKeyDown);
begin
inherited;
case Message.CharCode of
vk_up:
begin
UpClick (Self);
Message.Result := 0;
Exit;
end;
vk_down:
begin
DownClick(Self);
Message.Result := 0;
Exit;
end;
end;
inherited;
end;
procedure TInspSpinEdit.KeyDown(var Key: Word; Shift: TShiftState);
begin
case key of
VK_DELETE: if not FEditorEnabled then Key := 0;
VK_RETURN:
if FReturnIsTab then
begin
Key := vk_tab;
PostMessage(self.Handle,wm_keydown,VK_TAB,0);
end;
end;
inherited KeyDown(Key, Shift);
end;
procedure TInspSpinEdit.KeyPress(var Key: Char);
begin
if not IsValidChar(Key) then
begin
Key := #0;
MessageBeep(0)
end;
if Key <> #0 then
inherited KeyPress(Key);
end;
function TInspSpinEdit.IsValidChar(var Key: Char): Boolean;
var
dp:integer;
s:string;
begin
Result := (IsNumChar(Key) or (Key = DecimalSeparator) or (Key = ThousandSeparator) or (Key = TimeSeparator) or (Key = DateSeparator) or (Key = '+') or (Key = '-')) or
((Key < #32) and (Key <> Chr(VK_RETURN)));
if (key = TimeSeparator) and (fSpinType <> sptTime) then Result := False;
if (key = DateSeparator) and (fSpinType <> sptDate) then Result := False;
if (FSpinType = sptFloat) and not ( (key = chr(VK_ESCAPE)) or (key = chr(VK_RETURN)) or (key = chr(VK_BACK))) then
begin
if key = ThousandSeparator then Key := DecimalSeparator;
if (key=DecimalSeparator) and (pos(decimalseparator,self.text)>0) then result:=false;
dp:=pos(decimalseparator,self.text);
if (FPrecision>0) and (dp>0) and (selstart>=dp) and (sellength=0) then
begin
if (length(self.text)>=dp+fPrecision) then result:=false;
end;
end;
if FSpinType = sptTime then
begin
s := Text;
if (key = TimeSeparator) and (Pos(TimeSeparator,s) > 0) then
begin
Delete(s,Pos(TimeSeparator,s),1);
if Pos(TimeSeparator,s) > 0 then
Result := False;
end;
end;
if not FEditorEnabled and Result and ((Key >= #32) or
(Key = Char(VK_BACK)) or (Key = Char(VK_DELETE))) then
Result := False;
end;
procedure TInspSpinEdit.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
Params.Style := Params.Style or ES_MULTILINE or WS_CLIPCHILDREN;
end;
procedure TInspSpinEdit.CreateWnd;
begin
inherited CreateWnd;
SetEditRect;
end;
procedure TInspSpinEdit.SetDirection(const value: TSpinDirection);
begin
if value <> FDirection then
begin
FDirection := Value;
FButton.Direction := Value;
self.Width := self.Width + 1;
self.Width := self.Width - 1;
end;
end;
procedure TInspSpinEdit.SetEditorEnabled(NewValue:boolean);
begin
FEditorEnabled := NewValue;
end;
procedure TInspSpinEdit.SetEditRect;
var
Loc: TRect;
Dist : integer;
begin
if BorderStyle = bsNone then
Dist := 1
else
Dist := 0;
SendMessage(Handle, EM_GETRECT, 0, LongInt(@Loc));
Loc.Bottom := ClientHeight + 1;
Loc.Right := ClientWidth - FButton.Width - 2 - Dist;
Loc.Top := Dist;
Loc.Left := Dist;
SendMessage(Handle, EM_SETRECTNP, 0, LongInt(@Loc));
SendMessage(Handle, EM_GETRECT, 0, LongInt(@Loc)); {debug}
end;
procedure TInspSpinEdit.WMSize(var Message: TWMSize);
var
MinHeight: Integer;
Dist:integer;
begin
inherited;
if BorderStyle=bsNone then Dist:=1 else Dist:=5;
MinHeight := GetMinHeight;
{ text edit bug: if size to less than minheight, then edit ctrl does
not display the text }
if Height < MinHeight then
Height := MinHeight
else if FButton <> nil then
begin
if NewStyleControls and Ctl3D then
FButton.SetBounds(Width - FButton.Width - Dist, 1, FButton.Width, Height - Dist)
else
FButton.SetBounds (Width - FButton.Width, 0, FButton.Width, Height - 3);
SetEditRect;
end;
end;
function TInspSpinEdit.GetMinHeight: Integer;
var
DC: HDC;
SaveFont: HFont;
I: Integer;
SysMetrics, Metrics: TTextMetric;
begin
DC := GetDC(0);
GetTextMetrics(DC, SysMetrics);
SaveFont := SelectObject(DC, Font.Handle);
GetTextMetrics(DC, Metrics);
SelectObject(DC, SaveFont);
ReleaseDC(0, DC);
I := SysMetrics.tmHeight;
if I > Metrics.tmHeight then I := Metrics.tmHeight;
if BorderStyle = bsSingle then
Result := Metrics.tmHeight + I div 4 + GetSystemMetrics(SM_CYBORDER) * 4 + 2
else
Result := Metrics.tmHeight + (I div 4) + 2;
end;
procedure TInspSpinEdit.UpClick (Sender: TObject);
begin
if ReadOnly then MessageBeep(0)
else
begin
case fSpinType of
sptNormal: Value := Value + FIncrement;
sptFloat: FloatValue := FloatValue + FIncrementFloat;
sptTime: begin
if selstart>=pos(TimeSeparator,text) then
begin
if selstart>=posfrom(TimeSeparator,text,pos(TimeSeparator,text)) then
TimeValue := TimeValue + encodetime(0,0,1,0)
else
TimeValue := TimeValue + encodetime(0,1,0,0);
end
else
TimeValue := TimeValue + encodetime(1,0,0,0)
end;
sptDate: begin
if selstart>=pos(DateSeparator,text) then
begin
if selstart>=posfrom(DateSeparator,text,pos(DateSeparator,text)) then
DateValue := IncYear(DateValue,1)
else
DateValue := IncMonth(DateValue,1);
end
else
DateValue := DateValue + 1;
end;
end;
if Assigned(FOnSpinUp) then
FOnSpinUp(Self);
if Assigned(FOnSpinChange) then
FOnSpinChange(Self);
end;
end;
procedure TInspSpinEdit.DownClick (Sender: TObject);
var
dt: TDateTime;
begin
if ReadOnly then MessageBeep(0)
else
begin
case fSpinType of
sptNormal: Value := Value - FIncrement;
sptFloat: FloatValue := FloatValue - FIncrementFloat;
sptTime:
begin
dt := TimeValue;
dt := dt + 1;
if SelStart >= Pos(TimeSeparator,text) then
begin
if SelStart >= PosFrom(TimeSeparator,Text,Pos(TimeSeparator,Text)) then
dt := dt - EncodeTime(0,0,1,0)
else
dt := dt - EncodeTime(0,1,0,0);
end
else
dt := dt - EncodeTime(1,0,0,0);
if dt > 1 then
dt := dt - 1;
TimeValue := dt;
end;
sptDate:
begin
if SelStart >= Pos(DateSeparator,text) then
begin
if SelStart >= PosFrom(DateSeparator,text,pos(DateSeparator,text)) then
DateValue := IncYear(DateValue,-1)
else
DateValue := IncMonth(DateValue,-1);
end
else
DateValue := DateValue - 1;
end;
end;
if Assigned(FOnSpinDown) then
FOnSpinDown(Self);
if Assigned(FOnSpinChange) then
FOnSpinChange(Self);
end;
end;
procedure TInspSpinEdit.WMPaste(var Message: TWMPaste);
begin
if not FEditorEnabled or ReadOnly then Exit;
inherited;
end;
procedure TInspSpinEdit.WMCut(var Message: TWMPaste);
begin
if not FEditorEnabled or ReadOnly then Exit;
inherited;
end;
procedure TInspSpinEdit.CMExit(var Message: TCMExit);
begin
inherited;
case fSpinType of
sptNormal:if CheckValue (Value) <> Value then SetValue (Value);
sptFloat:if CheckFloatValue (FloatValue) <> FloatValue then SetFloatValue (FloatValue);
sptTime:if CheckDateValue (TimeValue) <> TimeValue then SetTimeValue (TimeValue);
sptDate:if CheckDateValue (DateValue) <> DateValue then SetDateValue (DateValue);
end;
end;
function TInspSpinEdit.GetValue: LongInt;
begin
try
Result := StrToInt (Text);
except
Result := FMinValue;
end;
end;
function TInspSpinEdit.CheckFloatValue (NewValue: Double): Double;
begin
Result := NewValue;
if (FMaxFloatValue <> FMinFloatValue) then
begin
if NewValue < FMinFloatValue then
Result := FMinFloatValue
else if NewValue > FMaxFloatValue then
Result := FMaxFloatValue;
end;
end;
function TInspSpinEdit.GetFloatValue: Double;
begin
try
Result := StrToFloat (Text);
except
Result := FMinValue;
end;
end;
procedure TInspSpinEdit.SetFloatValue (NewValue: Double);
begin
if fPrecision=0 then
Text := FloatToStr (CheckFloatValue (NewValue))
else
Text := FloatToStrF (CheckFloatValue (NewValue),ffFixed,15,fPrecision);
end;
procedure TInspSpinEdit.SetValue (NewValue: LongInt);
begin
Text := IntToStr (CheckValue (NewValue));
if not FEditorEnabled then SelectAll;
end;
function TInspSpinEdit.CheckValue (NewValue: LongInt): LongInt;
begin
Result := NewValue;
if (FMaxValue <> FMinValue) then
begin
if NewValue < FMinValue then
Result := FMinValue
else if NewValue > FMaxValue then
Result := FMaxValue;
end;
end;
function TInspSpinEdit.CheckDateValue (NewValue: tDatetime): tdatetime;
begin
Result := NewValue;
if (FMaxDateValue <> FMinDateValue) then
begin
if NewValue < FMinDateValue then
Result := FMinDateValue
else if NewValue > FMaxDateValue then
Result := FMaxDateValue;
end;
end;
procedure TInspSpinEdit.CMEnter(var Message: TCMGotFocus);
begin
if AutoSelect and (not (csLButtonDown in ControlState) or not FeditorEnabled) then
SelectAll;
inherited;
end;
procedure TInspSpinEdit.SetSpinFlat(const value: boolean);
begin
fButton.fUpButton.flat:=value;
fButton.fDownButton.flat:=value;
fspinflat:=value;
end;
procedure TInspSpinEdit.SetSpinTransparent(const value: boolean);
begin
FButton.FUpButton.Transparent := Value;
FButton.FDownButton.Transparent := Value;
FSpinTransparent := Value;
self.Width:=self.Width + 1;
self.Width:=self.Width - 1;
end;
procedure TInspSpinEdit.SetPrecision(const Value: integer);
begin
FPrecision := Value;
if fSpinType = sptFloat then
Floatvalue := GetFloatValue;
end;
procedure TInspSpinEdit.SetSpinType(const Value: TInspSpinType);
begin
if FSpinType <> value then
FSpinType := Value;
case FSpinType of
sptFloat:Floatvalue := GetFloatValue;
sptNormal:self.Value := GetValue;
sptTime:self.TimeValue := GetTimeValue;
sptDate:self.DateValue := GetDateValue;
end;
end;
function TInspSpinEdit.GetTimeValue: tdatetime;
begin
try
Result := StrToTime(Text);
except
Result := 0;
end;
end;
procedure TInspSpinEdit.SetTimeValue(const Value: tdatetime);
var
ss: Integer;
begin
fTimeValue := Value;
if (csLoading in ComponentState) then
Exit;
ss := SelStart;
Text := TimeToStr(value);
SelStart := ss;
end;
function TInspSpinEdit.GetDateValue: tdatetime;
begin
if (Text = '0') or (Text = '') then Result := Now
else
try
Result := StrToDate(Text);
except
Result := FMinDateValue;
end;
end;
procedure TInspSpinEdit.SetDateValue(const Value: tdatetime);
var
ss: Integer;
begin
FDateValue := Value;
if (csLoading in ComponentState) then
Exit;
FDateValue := CheckDateValue(value);
ss := SelStart;
Text := DateToStr(FDateValue);
SelStart := ss;
end;
procedure TInspSpinEdit.SetIsWinXP(const Value: Boolean);
begin
FIsWinXP := Value;
FButton.IsWinXP := Value;
end;
{TAdvTimerSpeedButton}
destructor TAdvTimerSpeedButton.Destroy;
begin
if FRepeatTimer <> nil then
FRepeatTimer.Free;
inherited Destroy;
end;
procedure TAdvTimerSpeedButton.MouseDown(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer);
begin
inherited MouseDown (Button, Shift, X, Y);
if tbAllowTimer in FTimeBtnState then
begin
if FRepeatTimer = nil then
FRepeatTimer := TTimer.Create(Self);
FRepeatTimer.OnTimer := TimerExpired;
FRepeatTimer.Interval := InitRepeatPause;
FRepeatTimer.Enabled := True;
end;
invalidaterect(parent.handle,nil,true);
end;
procedure TAdvTimerSpeedButton.MouseUp(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer);
begin
inherited MouseUp (Button, Shift, X, Y);
if FRepeatTimer <> nil then
FRepeatTimer.Enabled := False;
InvalidateRect(Parent.handle,nil,True);
end;
procedure TAdvTimerSpeedButton.TimerExpired(Sender: TObject);
begin
FRepeatTimer.Interval := RepeatPause;
if (FState = bsDown) and MouseCapture then
begin
try
Click;
except
FRepeatTimer.Enabled := False;
raise;
end;
end;
end;
procedure TAdvTimerSpeedButton.Paint;
const
Flags: array[Boolean] of Integer = (0, DFCS_PUSHED);
Flats: array[Boolean] of Integer = (0, DFCS_FLAT);
var
R: TRect;
HTheme: THandle;
begin
R := GetClientRect;
if DoVisualStyles then
begin
htheme := OpenThemeData((Owner as TWinControl).Handle,'spin');
case FButtonDirection of
bdLeft:
begin
if FState = bsDown then
DrawThemeBackground(htheme,Canvas.Handle,SPNP_DOWNHORZ,DNHZS_PRESSED,@r,nil)
else
DrawThemeBackground(htheme,Canvas.Handle,SPNP_DOWNHORZ,DNHZS_NORMAL,@r,nil);
end;
bdRight:
begin
if FState = bsDown then
DrawThemeBackground(htheme,Canvas.Handle,SPNP_UPHORZ,UPHZS_PRESSED,@r,nil)
else
DrawThemeBackground(htheme,Canvas.Handle,SPNP_UPHORZ,UPHZS_NORMAL,@r,nil);
end;
bdUp:
begin
if FState = bsDown then
DrawThemeBackground(htheme,Canvas.Handle,SPNP_UP,UPS_PRESSED,@r,nil)
else
DrawThemeBackground(htheme,Canvas.Handle,SPNP_UP,UPS_NORMAL,@r,nil);
end;
bdDown:
begin
if FState = bsDown then
DrawThemeBackground(htheme,Canvas.Handle,SPNP_DOWN,DNS_PRESSED,@r,nil)
else
DrawThemeBackground(htheme,Canvas.Handle,SPNP_DOWN,DNS_NORMAL,@r,nil);
end;
end;
CloseThemeData(htheme);
end
else
begin
case FButtonDirection of
bdLeft:DrawFrameControl(Canvas.Handle,r,DFC_SCROLL,DFCS_SCROLLLEFT or flags[fState=bsDown] or flats[flat]);
bdRight:DrawFrameControl(Canvas.Handle,r,DFC_SCROLL,DFCS_SCROLLRIGHT or flags[fState=bsDown] or flats[flat]);
bdUp,bdDown:inherited Paint;
end;
end;
end;
function TAdvTimerSpeedButton.DoVisualStyles: Boolean;
begin
if FIsWinXP then
Result := IsThemeActive
else
Result := False;
end;
{ TInspEditButton }
constructor TInspEditButton.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
ControlStyle := ControlStyle - [csAcceptsControls, csSetCaption] +
[csFramed, csOpaque];
FButton := CreateButton;
Glyph := nil;
Width := 20;
Height := 25;
Font.Name := 'Arial';
Font.Style := [];
Font.Size := 10;
FButton.Caption := '..';
end;
function TInspEditButton.CreateButton: TAdvSpeedButton;
begin
Result := TAdvSpeedButton.Create(Self);
Result.OnClick := BtnClick;
Result.OnMouseUp := BtnMouseDown;
Result.Visible := True;
Result.Enabled := True;
Result.Parent := Self;
Result.Caption := '';
end;
procedure TInspEditButton.Notification(AComponent: TComponent;
Operation: TOperation);
begin
inherited Notification(AComponent, Operation);
if (Operation = opRemove) and (AComponent = FFocusControl) then
FFocusControl := nil;
end;
procedure TInspEditButton.AdjustSize (var W: Integer; var H: Integer);
begin
if (FButton = nil) or (csLoading in ComponentState) then Exit;
if W < 15 then W := 15;
FButton.SetBounds (0, 0, W, H);
end;
procedure TInspEditButton.SetBounds(ALeft, ATop, AWidth, AHeight: Integer);
var
W, H: Integer;
begin
W := AWidth;
H := AHeight;
AdjustSize (W, H);
inherited SetBounds (ALeft, ATop, W, H);
end;
procedure TInspEditButton.WMSize(var Message: TWMSize);
var
W, H: Integer;
begin
inherited;
{ check for minimum size }
W := Width;
H := Height;
AdjustSize (W, H);
if (W <> Width) or (H <> Height) then
inherited SetBounds(Left, Top, W, H);
Message.Result := 0;
end;
procedure TInspEditButton.BtnMouseDown (Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if Button = mbLeft then
begin
if (Sender = FButton) then FOnClick(Self);
if (FFocusControl <> nil) and FFocusControl.TabStop and
FFocusControl.CanFocus and (GetFocus <> FFocusControl.Handle) then
FFocusControl.SetFocus
else if TabStop and (GetFocus <> Handle) and CanFocus then
SetFocus;
end;
end;
procedure TInspEditButton.BtnClick(Sender: TObject);
begin
end;
procedure TInspEditButton.Loaded;
var
W, H: Integer;
begin
inherited Loaded;
W := Width;
H := Height;
AdjustSize (W, H);
if (W <> Width) or (H <> Height) then
inherited SetBounds (Left, Top, W, H);
end;
function TInspEditButton.GetGlyph: TBitmap;
begin
Result := FButton.Glyph;
end;
procedure TInspEditButton.SetGlyph(Value: TBitmap);
begin
FButton.Glyph := Value;
end;
procedure TInspEditButton.SetCaption(Value:string);
begin
FButton.Caption := Value;
end;
function TInspEditButton.GetCaption:string;
begin
Result := FButton.Caption;
end;
function TInspEditButton.GetNumGlyphs: TNumGlyphs;
begin
Result := FButton.NumGlyphs;
end;
procedure TInspEditButton.SetNumGlyphs(Value: TNumGlyphs);
begin
FButton.NumGlyphs := Value;
end;
procedure TInspEditButton.SetIsWinXP(const Value: Boolean);
begin
FIsWinXP := Value;
FButton.IsWinXP := Value;
end;
{ TSpinEdit }
constructor TInspEditBtn.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FButton := TInspEditButton.Create (Self);
FButton.Width := 18;
FButton.Height := 16;
FButton.Visible := True;
FButton.Parent := Self;
FButton.FocusControl := Self;
FButton.OnClick := BtnClick;
FButton.OnExit := BtnExit;
Text := '0';
ControlStyle := ControlStyle - [csSetCaption];
FEditorEnabled := True;
FRightAlign := False;
FUnitSize := 0;
end;
destructor TInspEditBtn.Destroy;
begin
FButton := nil;
inherited Destroy;
end;
procedure TInspEditBtn.DoEnter;
begin
inherited;
SetEditRect;
end;
procedure TInspEditBtn.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
if FRightAlign then
Params.Style := Params.Style or ES_MULTILINE or WS_CLIPCHILDREN or ES_RIGHT
else
Params.Style := Params.Style or ES_MULTILINE or WS_CLIPCHILDREN;
end;
procedure TInspEditBtn.CreateWnd;
begin
inherited CreateWnd;
Width := Width - 1;
Width := Width + 1;
SetEditRect;
ResizeControl;
end;
procedure TInspEditBtn.SetGlyph(value:TBitmap);
begin
FButton.Glyph := Value;
end;
function TInspEditBtn.GetGlyph:TBitmap;
begin
Result := FButton.Glyph;
end;
procedure TInspEditBtn.SetCaption(value:string);
begin
FButton.ButtonCaption := Value;
end;
function TInspEditBtn.GetCaption:string;
begin
Result := FButton.ButtonCaption;
end;
procedure TInspEditBtn.SetEditRect;
var
Loc: TRect;
begin
SendMessage(Handle, EM_GETRECT, 0, LongInt(@Loc));
Loc.Bottom := ClientHeight + 1; {+1 is workaround for windows paint bug}
Loc.Right := Loc.Left + ClientWidth - FButton.Width - 4;
if BorderStyle = bsNone then
begin
Loc.Top := 2;
Loc.Left := 2;
end
else
begin
Loc.Top := 1;
Loc.Left := 1;
end;
if not Ctl3D then
Loc.Left := 2;
SendMessage(Handle, EM_SETRECTNP, 0, LongInt(@Loc));
end;
procedure TInspEditBtn.ResizeControl;
var
MinHeight: Integer;
Dist:integer;
begin
if BorderStyle = bsNone then
Dist := 2
else
Dist := 5;
MinHeight := GetMinHeight;
// text edit bug: if size to less than minheight, then edit ctrl does
// not display the text
if Height < MinHeight then
Height := MinHeight
else if FButton <> nil then
begin
if NewStyleControls and Ctl3D then
FButton.SetBounds(Width - FButton.Width - Dist + 2, 0, FButton.Width, Height - Dist)
else
FButton.SetBounds (Width - FButton.Width + 2, 1, FButton.Width, Height - 3);
SetEditRect;
end;
Invalidate;
end;
procedure TInspEditBtn.WMSize(var Message: TWMSize);
begin
inherited;
ResizeControl;
end;
function TInspEditBtn.GetMinHeight: Integer;
var
DC: HDC;
SaveFont: HFont;
I: Integer;
SysMetrics, Metrics: TTextMetric;
begin
DC := GetDC(0);
GetTextMetrics(DC, SysMetrics);
SaveFont := SelectObject(DC, Font.Handle);
GetTextMetrics(DC, Metrics);
SelectObject(DC, SaveFont);
ReleaseDC(0, DC);
I := SysMetrics.tmHeight;
if I > Metrics.tmHeight then I := Metrics.tmHeight;
Result := Metrics.tmHeight + I div 4 {+ GetSystemMetrics(SM_CYBORDER) * 4};
end;
procedure TInspEditBtn.BtnClick (Sender: TObject);
begin
if Assigned(FOnClickBtn) then
FOnClickBtn(Sender);
end;
procedure TInspEditBtn.WMPaste(var Message: TWMPaste);
begin
if not FEditorEnabled or ReadOnly then Exit;
inherited;
end;
procedure TInspEditBtn.WMCut(var Message: TWMPaste);
begin
if not FEditorEnabled or ReadOnly then Exit;
inherited;
end;
procedure TInspEditBtn.CMExit(var Message: TCMExit);
begin
inherited;
end;
procedure TInspEditBtn.CMEnter(var Message: TCMGotFocus);
begin
if AutoSelect and not (csLButtonDown in ControlState) then
SelectAll;
inherited;
end;
procedure TInspEditBtn.SetRightAlign(value: boolean);
begin
if FRightAlign <> Value then
begin
FRightAlign := Value;
ReCreatewnd;
end;
end;
procedure TInspEditBtn.WMPaint(var Msg: TWMPAINT);
begin
inherited;
end;
procedure TInspEditBtn.KeyPress(var Key: Char);
begin
inherited;
end;
procedure TInspEditBtn.WMChar(var Message: TWMChar);
begin
if not FEditorEnabled then
Exit;
Inherited;
end;
procedure TInspEditBtn.BtnExit(Sender: TObject);
begin
if not EditorEnabled then
DoExit;
end;
procedure TInspEditBtn.KeyDown(var Key: Word; Shift: TShiftState);
begin
inherited;
if Key = VK_F4 then BtnClick(self);
end;
procedure TInspEditButton.SetFlat(const Value: Boolean);
begin
FFlat := Value;
FButton.Flat := FFlat;
end;
procedure TInspEditBtn.SetButtonWidth(const Value: Integer);
begin
FButtonWidth := Value;
FButton.Width := Value;
end;
procedure TInspEditBtn.SetIsWinXP(const Value: Boolean);
begin
FIsWinXP := Value;
FButton.IsWinXP := Value;
end;
{ TAdvSpeedButton }
procedure TAdvSpeedButton.CMMouseEnter(var Message: TMessage);
begin
inherited;
Hot := True;
Invalidate;
end;
procedure TAdvSpeedButton.CMMouseLeave(var Message: TMessage);
begin
inherited;
Hot := False;
Invalidate;
end;
function TAdvSpeedButton.DoVisualStyles: Boolean;
begin
if FIsWinXP then
Result := IsThemeActive
else
Result := False;
end;
procedure TAdvSpeedButton.Paint;
const
DownStyles: array[Boolean] of Integer = (BDR_RAISEDINNER, BDR_SUNKENOUTER);
var
PaintRect: TRect;
DrawFlags: Integer;
Offset: TPoint;
HTheme: THandle;
begin
Canvas.Font := Self.Font;
PaintRect := Rect(0, 0, Width, Height);
if DoVisualStyles then
begin
HTheme := OpenThemeData(Parent.Handle,'button');
if FState in [bsDown, bsExclusive] then
DrawThemeBackground(HTheme,Canvas.Handle, BP_PUSHBUTTON,PBS_PRESSED,@PaintRect,nil)
else
if Hot then
DrawThemeBackground(HTheme,Canvas.Handle, BP_PUSHBUTTON,PBS_HOT,@PaintRect,nil)
else
DrawThemeBackground(HTheme,Canvas.Handle, BP_PUSHBUTTON,PBS_NORMAL,@PaintRect,nil);
CloseThemeData(HTheme);
end
else
begin
if not FFlat then
begin
DrawFlags := DFCS_BUTTONPUSH or DFCS_ADJUSTRECT;
if FState in [bsDown, bsExclusive] then
DrawFlags := DrawFlags or DFCS_PUSHED;
DrawFrameControl(Canvas.Handle, PaintRect, DFC_BUTTON, DrawFlags);
end
else
begin
DrawEdge(Canvas.Handle, PaintRect, DownStyles[FState in [bsDown, bsExclusive]],
BF_MIDDLE or BF_RECT);
InflateRect(PaintRect, -1, -1);
end;
end;
if not (FState in [bsDown, bsExclusive]) then
begin
Offset.X := 0;
Offset.Y := 0;
end;
if Assigned(Glyph) then
if not Glyph.Empty then
begin
Glyph.Transparent := True;
Offset.X := 0;
Offset.Y := 0;
if Glyph.Width < Width then
Offset.X := (Width - Glyph.Width) shr 1;
if Glyph.Height < Height then
Offset.Y := (Height - Glyph.Height) shr 1;
if FState = bsDown then
Canvas.Draw(Offset.X + 1 ,Offset.Y + 1,Glyph)
else
Canvas.Draw(Offset.X ,Offset.Y,Glyph)
end;
SetBkMode(Canvas.Handle,Windows.TRANSPARENT);
if FState = bsDown then
Canvas.TextOut(7,2,Caption)
else
Canvas.TextOut(6,1,Caption)
end;
{ TInspDateTimePicker }
procedure TInspDateTimePicker.WMNCPaint (var Message: TMessage);
var
DC: HDC;
arect: TRect;
WindowBrush:hBrush;
begin
inherited;
DC := GetWindowDC(Handle);
WindowBrush:=0;
try
WindowBrush:=CreateSolidBrush(ColorToRGB(clwindow));
GetWindowRect(Handle, ARect);
OffsetRect(arect,-arect.Left,-arect.Top);
FrameRect(DC, ARect, WindowBrush);
InflateRect(arect,-1,-1);
FrameRect(DC, ARect, WindowBrush);
finally
DeleteObject(windowBrush);
ReleaseDC(Handle,DC);
end;
end;
procedure TInspColorComboBox.DrawItem(Index: Integer; Rect: TRect; State: TOwnerDrawState);
var
BC : TColor;
Nm : string;
begin
{get selected color and text to display}
case Index of
0: begin BC := clBlack; Nm := 'Black'; end;
1: begin BC := clMaroon; Nm := 'Maroon'; end;
2: begin BC := clGreen; Nm := 'Green'; end;
3: begin BC := clOlive; Nm := 'Olive'; end;
4: begin BC := clNavy; Nm := 'Navy'; end;
5: begin BC := clPurple; Nm := 'Purple'; end;
6: begin BC := clTeal; Nm := 'Teal'; end;
7: begin BC := clGray; Nm := 'Gray'; end;
8: begin BC := clSilver; Nm := 'Silver'; end;
9: begin BC := clRed; Nm := 'Red'; end;
10: begin BC := clLime; Nm := 'Lime'; end;
11: begin BC := clYellow; Nm := 'Yellow'; end;
12: begin BC := clBlue; Nm := 'Blue'; end;
13: begin BC := clFuchsia; Nm := 'Fuchsia'; end;
14: begin BC := clAqua; Nm := 'Aqua'; end;
15: begin BC := clWhite; Nm := 'White'; end;
16: begin BC := clBackGround; Nm := 'Background'; end;
17: begin BC := clActiveCaption; Nm := 'ActiveCaption'; end;
18: begin BC := clInActiveCaption; Nm := 'InactiveCaption'; end;
19: begin BC := clMenu; Nm := 'Menu'; end;
20: begin BC := clWindow; Nm := 'Window'; end;
21: begin BC := clWindowFrame; Nm := 'WindowFrame'; end;
22: begin BC := clMenuText; Nm := 'MenuText'; end;
23: begin BC := clWindowText; Nm := 'WindowText'; end;
24: begin BC := clCaptionText; Nm := 'CaptionText'; end;
25: begin BC := clActiveBorder; Nm := 'ActiveBorder'; end;
26: begin BC := clInactiveBorder; Nm := 'InactiveBorder'; end;
27: begin BC := clAppWorkSpace; Nm := 'AppWorkspace'; end;
28: begin BC := clHighLight; Nm := 'Highlight'; end;
29: begin BC := clHighLightText; Nm := 'HighlightText'; end;
30: begin BC := clBtnFace; Nm := 'BtnFace'; end;
31: begin BC := clBtnShadow; Nm := 'BtnShadow'; end;
32: begin BC := clGrayText; Nm := 'GrayText'; end;
33: begin BC := clBtnText; Nm := 'BtnText'; end;
34: begin BC := clInactiveCaptionText; Nm := 'InactiveCaptionText'; end;
35: begin BC := clBtnHighLight; Nm := 'BtnHighlight'; end;
36: begin BC := cl3DDkShadow; Nm := '3ddkShadow'; end;
37: begin BC := cl3DLight; Nm := '3dLight'; end;
38: begin BC := clInfoText; Nm := 'InfoText'; end;
39: begin BC := clInfoBk; Nm := 'Infobk'; end;
40: begin BC := FCustomColor; Nm := 'Custom Color ...'; end;
else
begin BC := clWhite; Nm := '???'; end;
end;
if (State * [odSelected, odFocused] <> []) then
begin
Canvas.Font.Color := clHighLightText;
Canvas.Brush.Color := clHighLight;
end
else
begin
Canvas.Font.Color := Font.Color;
Canvas.Brush.Color := Color;
end;
Canvas.Pen.Color := Canvas.Brush.Color;
Canvas.Rectangle(Rect.Left, Rect.Top, Rect.Right, Rect.Bottom);
Canvas.Pen.Color := clBlack;
Canvas.Brush.Color := BC;
Canvas.Rectangle(Rect.Left + 1, Rect.Top + 1, Rect.Left + 19, Rect.Bottom - 1);
Canvas.Brush.Color := clWhite;
Canvas.Pen.Color := clWhite;
Rect.Left := Rect.Left + 22;
SetBkMode(Canvas.Handle,TRANSPARENT);
DrawText(Canvas.Handle,@Nm[1],Length(Nm),Rect,DT_LEFT or DT_VCENTER or DT_SINGLELINE);
end;
function TInspColorComboBox.GetColorValue: TColor;
begin
Result := clBlack;
case ItemIndex of
0: Result := clBlack;
1: Result := clMaroon;
2: Result := clGreen;
3: Result := clOlive;
4: Result := clNavy;
5: Result := clPurple;
6: Result := clTeal;
7: Result := clGray;
8: Result := clSilver;
9: Result := clRed;
10: Result := clLime;
11: Result := clYellow;
12: Result := clBlue;
13: Result := clFuchsia;
14: Result := clAqua;
15: Result := clWhite;
16: Result := clBackGround;
17: Result := clActiveCaption;
18: Result := clInActiveCaption;
19: Result := clMenu;
20: Result := clWindow;
21: Result := clWindowFrame;
22: Result := clMenuText;
23: Result := clWindowText;
24: Result := clCaptionText;
25: Result := clActiveBorder;
26: Result := clInactiveBorder;
27: Result := clAppWorkSpace;
28: Result := clHighLight;
29: Result := clHighLightText;
30: Result := clBtnFace;
31: Result := clBtnShadow;
32: Result := clGrayText;
33: Result := clBtnText;
34: Result := clInactiveCaptionText;
35: Result := clBtnHighLight;
36: Result := cl3DDkShadow;
37: Result := cl3DLight;
38: Result := clInfoText;
39: Result := clInfoBk;
40: Result := FCustomColor;
end;
end;
procedure TInspColorComboBox.SetColorValue(const Value: TColor);
begin
case Value of
clBlack: ItemIndex := 0;
clMaroon: ItemIndex := 1;
clGreen: ItemIndex := 2;
clOlive: ItemIndex := 3;
clNavy: ItemIndex := 4;
clPurple: ItemIndex := 5;
clTeal: ItemIndex := 6;
clGray: ItemIndex := 7;
clSilver: ItemIndex := 8;
clRed: ItemIndex := 9;
clLime: ItemIndex := 10;
clYellow: ItemIndex := 11;
clBlue: ItemIndex := 12;
clFuchsia: ItemIndex := 13;
clAqua: ItemIndex := 14;
clWhite: ItemIndex := 15;
clBackGround: ItemIndex := 16;
clActiveCaption: ItemIndex := 17;
clInActiveCaption: ItemIndex := 18;
clMenu: ItemIndex := 19;
clWindow: ItemIndex := 20;
clWindowFrame: ItemIndex := 21;
clMenuText: ItemIndex := 22;
clWindowText: ItemIndex := 23;
clCaptionText: ItemIndex := 24;
clActiveBorder: ItemIndex := 25;
clInactiveBorder: ItemIndex := 26;
clAppWorkSpace: ItemIndex := 27;
clHighLight: ItemIndex := 28;
clHighLightText: ItemIndex := 29;
clBtnFace: ItemIndex := 30;
clBtnShadow: ItemIndex := 31;
clGrayText: ItemIndex := 32;
clBtnText: ItemIndex := 33;
clInactiveCaptionText: ItemIndex := 34;
clBtnHighLight: ItemIndex := 35;
cl3DDkShadow: ItemIndex := 36;
cl3DLight: ItemIndex := 37;
clInfoText: ItemIndex := 38;
clInfoBk: ItemIndex := 39;
else
begin
ItemIndex := 40;
CustomColor := Value;
end;
end;
end;
end.
|
{$MODE OBJFPC}
unit entity;
interface
uses
model,camera;
type
TPosition=record
x,y,z:extended;
end;
type
TEntity=class;
type
TOnMouseLeftFunc =procedure(Sender:TEntity);
TOnMouseRightFunc =procedure(Sender:TEntity);
TOnSelectFunc =procedure(Sender:TEntity);
TOnCreateFunc =procedure(Sender:TEntity);
TOnDestroyFunc =procedure(Sender:TEntity);
type
TEntityEvent=class
private
MouseLeftFunc :TOnMouseLeftFunc;
MouseRightFunc :TOnMouseRightFunc;
SelectFunc :TOnSelectFunc;
CreateFunc :TOnCreateFunc;
DestroyFunc :TOnDestroyFunc;
public
constructor Create;
property OnMouseLeft :TOnMouseLeftFunc
read MouseLeftFunc write MouseLeftFunc;
property OnMouseRight :TOnMouseRightFunc
read MouseRightFunc write MouseRightFunc;
property OnSelect :TOnSelectFunc
read SelectFunc write SelectFunc;
property OnCreate :TOnCreateFunc
read CreateFunc write CreateFunc;
property OnDestroy :TOnDestroyFunc
read DestroyFunc write DestroyFunc;
end;
type
TEntity=class
private
pos:TPosition;
mdl:TModel;
lkud,lkar:extended;
cmr:TCamera;
event:TEntityEvent;
public
constructor Create;
constructor Create(p:TPosition;c:TCamera;e:TEntityEvent);
procedure Redraw;
procedure Trs(p:TPosition);
procedure Mov(t:longint);
procedure Rot(ud,ar:extended);
property Models:TModel read mdl write mdl;
end;
implementation
constructor TentityEvent.Create;
begin
MouseLeftFunc :=NIL;
MouseRightFunc :=NIL;
SelectFunc :=NIL;
CreateFunc :=NIL;
DestroyFunc :=NIL;
end;
constructor TEntity.Create;
begin
event:=TEntityEvent.Create;
with pos do begin
x:=0;
y:=0;
z:=0;
end;
lkud:=0;
lkar:=0;
cmr:=NIL;
end;
constructor TEntity.Create(p:TPosition;c:TCamera;e:TEntityEvent);
begin
event:=e;
pos:=p;
cmr:=c;
lkud:=0;
lkar:=0;
end;
procedure TEntity.Redraw;
begin
end;
procedure TEntity.Trs(p:TPosition);
begin
end;
procedure TEntity.Mov(t:longint);
begin
end;
procedure TEntity.Rot(ud,ar:extended);
begin
end;
end. |
{ dependency: pl_indy
Edit copy_demo_files.cmd before compiling
Run this demo and note the tray icon to open log or exit
Browse to http://localhost
Demo will reply with "Hello world!"
}
unit FormMain;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
Menus, lclintf, MyServer;
type
{ TForm1 }
TForm1 = class(TForm)
miExit: TMenuItem;
miOpenLog: TMenuItem;
pmMain: TPopupMenu;
TrayIcon: TTrayIcon;
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure miExitClick(Sender: TObject);
procedure miOpenLogClick(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
Server : THTTPServer;
end;
const
LogFile = 'server.log';
var
Form1: TForm1;
implementation
{$R *.frm}
{ TForm1 }
procedure TForm1.miExitClick(Sender: TObject);
begin
Close;
end;
procedure TForm1.miOpenLogClick(Sender: TObject);
begin
if FileExists(LogFile) then OpenDocument(LogFile);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Server := THTTPServer.Create(nil);
Server.Active := True;
end;
procedure TForm1.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin
Server.Free;
end;
end.
|
unit evControlParaHotSpot;
{* Реализация "горячей точки" для параграфа, представляющего контрол ввода }
// Модуль: "w:\common\components\gui\Garant\Everest\evControlParaHotSpot.pas"
// Стереотип: "SimpleClass"
// Элемент модели: "TevControlParaHotSpot" MUID: (4A27A7D5019E)
{$Include w:\common\components\gui\Garant\Everest\evDefine.inc}
interface
{$If Defined(evNeedHotSpot)}
uses
l3IntfUses
, k2TagTool
, nevGUIInterfaces
, nevTools
, evQueryCardInt
, l3Units
, l3Variant
, afwInterfaces
;
type
_X_ = InevTextPara;
_nevParaXTool_Parent_ = Tk2TagTool;
{$Include w:\common\components\gui\Garant\Everest\new\nevParaXTool.imp.pas}
TevControlParaHotSpot = class(_nevParaXTool_, IevMouseMoveHandler, IevHotSpot)
{* Реализация "горячей точки" для параграфа, представляющего контрол ввода }
private
thisMap: InevMap;
f_OldChecked: Boolean;
f_ControlFriend: IevControlFriend;
private
function PtInButton(const aPt: TafwPoint): Boolean;
{* Щелчок по кнопке редактора }
function PtInCtrButton(const aPt: Tl3Point): Boolean;
{* Щелчок по кнопке-параграфу }
function PtInPara(const aPt: TafwPoint): Boolean;
function PtToPara(const aPt: TafwPoint): Tl3Point;
{* переводит из глобальных координат в координаты параграфа }
procedure TrySendToGroup(aTag: Tl3Variant);
protected
function pm_GetControlFriend: IevControlFriend;
function pm_GetVisible: Boolean; virtual;
procedure CheckMapValid(const aView: InevControlView);
function TransMouseMove(const aView: InevControlView;
const aKeys: TevMouseState;
out theActiveElement: InevActiveElement): Boolean;
{* Собственно реальный MouseMove, передаваемый редактору }
function MouseMove(const aView: InevControlView;
const Keys: TevMouseState): Boolean;
{* Обрабатывает перемещение мыши }
function LButtonDown(const aView: InevControlView;
const Keys: TevMouseState;
var Effect: TevMouseEffect): Boolean;
{* Обрабатывает нажатие левой кнопки мыши }
function LButtonUp(const aView: InevControlView;
const Keys: TevMouseState): Boolean;
{* Обрабатывает отпускание левой кнопки мыши }
function LButtonDoubleClick(const aView: InevControlView;
const Keys: TevMouseState;
var Effect: TevMouseEffect): Boolean;
{* Обрабатывает двойное нажатие левой кнопки мыши }
function RButtonDown(const aView: InevControlView;
const Keys: TevMouseState): Boolean;
{* Обрабатывает нажатие правой кнопки мыши }
function RButtonUp(const aView: InevControlView;
const Keys: TevMouseState): Boolean;
{* Обрабатывает отпускание правой конопки мыши }
function MButtonDown(const aView: InevControlView;
const Keys: TevMouseState): Boolean;
{* Обрабатывает нажатие колеса мыши }
function MButtonUp(const aView: InevControlView;
const Keys: TevMouseState): Boolean;
{* Обрабатывает отпускание колеса мыши }
function CanDrag: Boolean;
procedure Cleanup; override;
{* Функция очистки полей объекта. }
procedure ClearFields; override;
public
constructor Create(const aMap: InevMap;
aTagWrap: Tl3Variant); reintroduce;
class function Make(const aMap: InevMap;
aTagWrap: Tl3Variant): IevHotSpot; reintroduce;
{* Фабричный метод }
procedure HitTest(const aView: InevControlView;
const aState: TafwCursorState;
var theInfo: TafwCursorInfo);
private
property Visible: Boolean
read pm_GetVisible;
{* Видимость контрола }
protected
property ControlFriend: IevControlFriend
read pm_GetControlFriend;
end;//TevControlParaHotSpot
{$IfEnd} // Defined(evNeedHotSpot)
implementation
{$If Defined(evNeedHotSpot)}
uses
l3ImplUses
, evdTypes
, SysUtils
, evControlParaConst
, evMsgCode
, k2Tags
, ControlsBlock_Const
{$If Defined(k2ForEditor)}
, evParaTools
{$IfEnd} // Defined(k2ForEditor)
//#UC START# *4A27A7D5019Eimpl_uses*
//#UC END# *4A27A7D5019Eimpl_uses*
;
type _Instance_R_ = TevControlParaHotSpot;
{$Include w:\common\components\gui\Garant\Everest\new\nevParaXTool.imp.pas}
function TevControlParaHotSpot.pm_GetControlFriend: IevControlFriend;
//#UC START# *4A27AC32013C_4A27A7D5019Eget_var*
//#UC END# *4A27AC32013C_4A27A7D5019Eget_var*
begin
//#UC START# *4A27AC32013C_4A27A7D5019Eget_impl*
if (f_ControlFriend = nil) then
Supports(ParaX, IevControlFriend, f_ControlFriend);
Result := f_ControlFriend;
//#UC END# *4A27AC32013C_4A27A7D5019Eget_impl*
end;//TevControlParaHotSpot.pm_GetControlFriend
function TevControlParaHotSpot.pm_GetVisible: Boolean;
//#UC START# *4A27AC74011B_4A27A7D5019Eget_var*
//#UC END# *4A27AC74011B_4A27A7D5019Eget_var*
begin
//#UC START# *4A27AC74011B_4A27A7D5019Eget_impl*
Result := GetRedirect.BoolA[k2_tiVisible];
//#UC END# *4A27AC74011B_4A27A7D5019Eget_impl*
end;//TevControlParaHotSpot.pm_GetVisible
function TevControlParaHotSpot.PtInButton(const aPt: TafwPoint): Boolean;
{* Щелчок по кнопке редактора }
//#UC START# *4A27AD7103E7_4A27A7D5019E_var*
var
l_ButtonLeft : Integer;
l_ButtonWidth : Integer;
//#UC END# *4A27AD7103E7_4A27A7D5019E_var*
begin
//#UC START# *4A27AD7103E7_4A27A7D5019E_impl*
if not (Assigned(thisMap) and Assigned(thisMap.FI)) then
begin
Result := False;
Exit;
end//FI^ = nil
else
l_ButtonLeft := thisMap.Bounds.Left + thisMap.FI.Width;
l_ButtonWidth := GetRedirect.IntA[k2_tiRightIndent];
Result := (aPt.X > l_ButtonLeft) and (aPt.X < l_ButtonLeft + l_ButtonWidth);
//#UC END# *4A27AD7103E7_4A27A7D5019E_impl*
end;//TevControlParaHotSpot.PtInButton
function TevControlParaHotSpot.PtInCtrButton(const aPt: Tl3Point): Boolean;
{* Щелчок по кнопке-параграфу }
//#UC START# *4A27AD97018A_4A27A7D5019E_var*
var
l_ButtonLeft : Integer;
l_ButtonWidth : Integer;
l_ButtonUp : Integer;
l_ButtonDown : Integer;
//#UC END# *4A27AD97018A_4A27A7D5019E_var*
begin
//#UC START# *4A27AD97018A_4A27A7D5019E_impl*
l_ButtonLeft := GetRedirect.IntA[k2_tiLeftIndent];
l_ButtonWidth := thisMap.FI.Width;
l_ButtonUp := GetRedirect.IntA[k2_tiSpaceBefore] div 2;
l_ButtonDown := thisMap.FI.Height - GetRedirect.IntA[k2_tiSpaceAfter] div 2;
Result := (aPt.X > l_ButtonLeft) and (aPt.X < l_ButtonWidth) and
(aPt.Y > l_ButtonUp) and (aPt.Y < l_ButtonDown);
//#UC END# *4A27AD97018A_4A27A7D5019E_impl*
end;//TevControlParaHotSpot.PtInCtrButton
function TevControlParaHotSpot.PtInPara(const aPt: TafwPoint): Boolean;
//#UC START# *4A27ADBA0100_4A27A7D5019E_var*
//#UC END# *4A27ADBA0100_4A27A7D5019E_var*
begin
//#UC START# *4A27ADBA0100_4A27A7D5019E_impl*
Result := Tl3Rect(thisMap.Bounds).ContainsPt(aPt);
//#UC END# *4A27ADBA0100_4A27A7D5019E_impl*
end;//TevControlParaHotSpot.PtInPara
function TevControlParaHotSpot.PtToPara(const aPt: TafwPoint): Tl3Point;
{* переводит из глобальных координат в координаты параграфа }
//#UC START# *4A27ADCF011E_4A27A7D5019E_var*
//#UC END# *4A27ADCF011E_4A27A7D5019E_var*
begin
//#UC START# *4A27ADCF011E_4A27A7D5019E_impl*
Result := Tl3Point(aPt).Sub(Tl3Rect(thisMap.Bounds).TopLeft);
//#UC END# *4A27ADCF011E_4A27A7D5019E_impl*
end;//TevControlParaHotSpot.PtToPara
procedure TevControlParaHotSpot.TrySendToGroup(aTag: Tl3Variant);
var l_Tag: Tl3Tag;
var l_Group: IevQueryGroup;
//#UC START# *4A27ADED0094_4A27A7D5019E_var*
//#UC END# *4A27ADED0094_4A27A7D5019E_var*
begin
//#UC START# *4A27ADED0094_4A27A7D5019E_impl*
if evInPara(aTag, k2_typControlsBlock, l_Tag) then
begin
if l_Tag.QT(IevQueryGroup, l_Group) then
try
l_Group.ClickOnDisabledLabel;
finally
l_Group := nil;
end;//try..finally
end;//evInPara(aTag, k2_idControlsBlock, l_Tag)
//#UC END# *4A27ADED0094_4A27A7D5019E_impl*
end;//TevControlParaHotSpot.TrySendToGroup
procedure TevControlParaHotSpot.CheckMapValid(const aView: InevControlView);
//#UC START# *52FC8C800193_4A27A7D5019E_var*
//#UC END# *52FC8C800193_4A27A7D5019E_var*
begin
//#UC START# *52FC8C800193_4A27A7D5019E_impl*
if Assigned(thisMap) and not thisMap.IsMapValid then
thisMap := aView.MapByPoint(ParaX.MakePoint);
//#UC END# *52FC8C800193_4A27A7D5019E_impl*
end;//TevControlParaHotSpot.CheckMapValid
constructor TevControlParaHotSpot.Create(const aMap: InevMap;
aTagWrap: Tl3Variant);
//#UC START# *4A27AE0B0219_4A27A7D5019E_var*
//#UC END# *4A27AE0B0219_4A27A7D5019E_var*
begin
//#UC START# *4A27AE0B0219_4A27A7D5019E_impl*
inherited Create(aTagWrap);
thisMap := aMap;
//#UC END# *4A27AE0B0219_4A27A7D5019E_impl*
end;//TevControlParaHotSpot.Create
class function TevControlParaHotSpot.Make(const aMap: InevMap;
aTagWrap: Tl3Variant): IevHotSpot;
{* Фабричный метод }
var
l_Inst : TevControlParaHotSpot;
begin
l_Inst := Create(aMap, aTagWrap);
try
Result := l_Inst;
finally
l_Inst.Free;
end;//try..finally
end;//TevControlParaHotSpot.Make
procedure TevControlParaHotSpot.HitTest(const aView: InevControlView;
const aState: TafwCursorState;
var theInfo: TafwCursorInfo);
//#UC START# *48E2622A03C4_4A27A7D5019E_var*
var
l_Control : IevEditorControl;
//#UC END# *48E2622A03C4_4A27A7D5019E_var*
begin
//#UC START# *48E2622A03C4_4A27A7D5019E_impl*
inherited;
if Visible then
begin
CheckMapValid(aView);
if (ControlFriend.ControlType = ev_ctLabel) then
theInfo.rCursor := ev_csArrow
else
if (ControlFriend.ControlType in evButtonStyleControls) then
theInfo.rCursor := ev_csArrow
else
if (ControlFriend.ControlType in evControlsWithButtons) then
begin
if PtInButton(aState.rPoint) then
theInfo.rCursor := ev_csArrow
else
theInfo.rCursor := ev_csIBeam;
end//ControlType in evControlsWithButtons
else
if (ControlFriend.ControlType in evSimpleEditors) then
theInfo.rCursor := ev_csIBeam;
l_Control := ControlFriend.GetControl;
if (l_Control <> nil) then
try
if l_Control.GetHint(theInfo.rHint) then
Exit;
finally
l_Control := nil;
end;//try..finally
end;//Visible
theInfo.rHint := nil;
//#UC END# *48E2622A03C4_4A27A7D5019E_impl*
end;//TevControlParaHotSpot.HitTest
function TevControlParaHotSpot.TransMouseMove(const aView: InevControlView;
const aKeys: TevMouseState;
out theActiveElement: InevActiveElement): Boolean;
{* Собственно реальный MouseMove, передаваемый редактору }
//#UC START# *48E2638F0358_4A27A7D5019E_var*
var
l_Pt : Tl3Point;
l_Control : IevEditorControl;
l_Upper : Boolean;
//#UC END# *48E2638F0358_4A27A7D5019E_var*
begin
//#UC START# *48E2638F0358_4A27A7D5019E_impl*
Result := True;
with ControlFriend do
if (ControlType in evFlatBTNControls) and Visible and Enabled then
begin
CheckMapValid(aView);
l_Pt := PtToPara(aKeys.rPoint);
l_Upper := PtInCtrButton(l_Pt);
if (l_Upper <> Upper) then
begin
l_Control := ControlFriend.GetControl;
if (l_Control <> nil) then
begin
l_Control.Upper := l_Upper;
if l_Upper then
l_Control.UpperChange;
end;//l_Control <> nil
end;//l_Upper <> Upper
end;//ControlType in evFlatBTNControls..
//#UC END# *48E2638F0358_4A27A7D5019E_impl*
end;//TevControlParaHotSpot.TransMouseMove
function TevControlParaHotSpot.MouseMove(const aView: InevControlView;
const Keys: TevMouseState): Boolean;
{* Обрабатывает перемещение мыши }
//#UC START# *48E266730188_4A27A7D5019E_var*
//#UC END# *48E266730188_4A27A7D5019E_var*
begin
//#UC START# *48E266730188_4A27A7D5019E_impl*
Result := False;
if not ControlFriend.Enabled then
Exit;
CheckMapValid(aView);
with ControlFriend do
case ControlType of
ev_ctButton, ev_ctStateButton:
begin
Result := True;
if not PtInPara(Keys.rPoint) then
// - отпускаем кнопку
begin
Checked := False;
Upper := False;
end//if not PtInPara(Keys.rPoint) then
else
Checked := True;
// - возвращаем в нажатое состояние
end;//ev_ctButton
ev_ctCheckEdit, ev_ctRadioEdit:
begin
if not PtInPara(Keys.rPoint) then
Checked := f_OldChecked
// - восстанавливаем старое значение
else
Checked := not f_OldChecked;
// - восстанавливаем новое значение
Result := True;
end;//ev_ctCheckEdit, ev_ctRadioEdit
else
;
end;//Case ControlType
//#UC END# *48E266730188_4A27A7D5019E_impl*
end;//TevControlParaHotSpot.MouseMove
function TevControlParaHotSpot.LButtonDown(const aView: InevControlView;
const Keys: TevMouseState;
var Effect: TevMouseEffect): Boolean;
{* Обрабатывает нажатие левой кнопки мыши }
//#UC START# *48E266AA00A4_4A27A7D5019E_var*
var
l_Pt : Tl3Point;
l_Control : IevEditorControl;
//#UC END# *48E266AA00A4_4A27A7D5019E_var*
begin
//#UC START# *48E266AA00A4_4A27A7D5019E_impl*
Result := False;
if not ControlFriend.Enabled then
begin
Result := true;
Effect.rNeedAsyncLoop := false;
Exit;
end;//not ControlFriend.Enabled
CheckMapValid(aView);
l_Pt := PtToPara(Keys.rPoint);
// - переводим из глобальных координат в координаты параграфа
with ControlFriend do
case ControlType of
ev_ctButton, ev_ctStateButton, ev_ctLabel, ev_ctPictureLabel:
begin
l_Control := ControlFriend.GetControl;
if (l_Control <> nil) then
try
Result := l_Control.LMouseBtnDown(aView, ParaX, l_Pt, Keys, PtInPara(Keys.rPoint), thisMap);
Checked := True;
//Result := True;
finally
l_Control := nil;
end
else //Если какой-то из этих контролов не имеет отображения в модели, то и нечего ему фокус ловить.
begin
TrySendToGroup(GetRedirect);
//Result := True;
end;
end;//ev_ctButton
ev_ctCheckEdit, ev_ctRadioEdit:
begin
aView.Control.Selection.SelectPt(Keys.rPoint, True);
// - переводим фокус на контрол
f_OldChecked := Checked;
if PtInPara(Keys.rPoint) then
Checked := not f_OldChecked;
// - инвертируем значение
Result := True;
end;//ev_ctCheckEdit, ev_ctRadioEdit
ev_ctEllipsesEdit, ev_ctSpinedit, ev_ctEdit, ev_ctCombo, ev_ctCalEdit, ev_ctEmailEdit:
begin
l_Control := ControlFriend.GetControl;
if (l_Control <> nil) then
try
Result := l_Control.LMouseBtnDown(aView, ParaX, l_Pt, Keys, True, thisMap);
if Result then
begin
aView.Control.Selection.SelectPt(Keys.rPoint, True);
Checked := True;
end;
//Result := True;
finally
l_Control := nil;
end;
end;//ev_ctEllipsesEdit, ev_ctSpinedit, ev_ctCombo, ev_ctCalEdit
end;//Case ControlType
//#UC END# *48E266AA00A4_4A27A7D5019E_impl*
end;//TevControlParaHotSpot.LButtonDown
function TevControlParaHotSpot.LButtonUp(const aView: InevControlView;
const Keys: TevMouseState): Boolean;
{* Обрабатывает отпускание левой кнопки мыши }
//#UC START# *48E266C70128_4A27A7D5019E_var*
var
l_Pt : Tl3Point;
l_Control : IevEditorControl;
//#UC END# *48E266C70128_4A27A7D5019E_var*
begin
//#UC START# *48E266C70128_4A27A7D5019E_impl*
Result := False;
if not ControlFriend.Enabled then
begin
Result := true;
Exit;
end;//not ControlFriend.Enabled
CheckMapValid(aView);
l_Pt := PtToPara(Keys.rPoint);
// - переводим из глобальных координат в координаты параграфа
with ControlFriend do
case ControlType of
ev_ctButton, ev_ctStateButton:
begin
Checked := False;
Upper := False;
l_Control := ControlFriend.GetControl;
if (l_Control <> nil) then
try
Result := l_Control.LMouseBtnUp(aView, ParaX, l_Pt, Keys, PtInPara(Keys.rPoint));
finally
l_Control := nil;
end;
end;//ev_ctButton
ev_ctCheckEdit, ev_ctRadioEdit:
begin
if not PtInPara(Keys.rPoint) then
Checked := f_OldChecked
// - восстанавливаем старое значение
else
Checked := not f_OldChecked;
// - восстанавливаем новое значение
Result := True;
end;//ev_ctCheckEdit, ev_ctRadioEdit
ev_ctEllipsesEdit, ev_ctSpinedit, ev_ctEdit, ev_ctCombo, ev_ctCalEdit, ev_ctEmailEdit:
begin
Checked := False;
Result := True;
end;
end;//Case ControlType
//#UC END# *48E266C70128_4A27A7D5019E_impl*
end;//TevControlParaHotSpot.LButtonUp
function TevControlParaHotSpot.LButtonDoubleClick(const aView: InevControlView;
const Keys: TevMouseState;
var Effect: TevMouseEffect): Boolean;
{* Обрабатывает двойное нажатие левой кнопки мыши }
//#UC START# *48E266DE026B_4A27A7D5019E_var*
//#UC END# *48E266DE026B_4A27A7D5019E_var*
begin
//#UC START# *48E266DE026B_4A27A7D5019E_impl*
CheckMapValid(aView);
Result := (ControlFriend.ControlType in evNotEditableControls) or
((ControlFriend.ControlType in evControlsWithButtons) and PtInButton(Keys.rPoint));
//#UC END# *48E266DE026B_4A27A7D5019E_impl*
end;//TevControlParaHotSpot.LButtonDoubleClick
function TevControlParaHotSpot.RButtonDown(const aView: InevControlView;
const Keys: TevMouseState): Boolean;
{* Обрабатывает нажатие правой кнопки мыши }
//#UC START# *48E266FB01FC_4A27A7D5019E_var*
var
l_Control: IevEditorControl;
l_Point: InevPoint;
l_op: InevOp;
//#UC END# *48E266FB01FC_4A27A7D5019E_var*
begin
//#UC START# *48E266FB01FC_4A27A7D5019E_impl*
CheckMapValid(aView);
Result := False;
l_Control := ControlFriend.GetControl;
if (l_Control <> nil) then
try
if (l_Control.ControlType in evEditControls) and
Supports(aView.PointByPt(Keys.rPoint), InevPoint, l_Point) then
with aView.Control.Selection do
if not Contains(l_Point) then
begin
l_Op := aView.Control.Processor.StartOp(ev_msgMove);
try
// !STUB! По хорошему это дело редактора, но до введение понятия "невыбираемых
// параграфов жить будет здесь
SelectPoint(l_Point, False);
l_Control.Req.QueryCard.RememberFocusControl(l_Control);
l_Control.RememberState;
finally
l_op := nil;
end;
end;
finally
l_Control := nil;
end;
//#UC END# *48E266FB01FC_4A27A7D5019E_impl*
end;//TevControlParaHotSpot.RButtonDown
function TevControlParaHotSpot.RButtonUp(const aView: InevControlView;
const Keys: TevMouseState): Boolean;
{* Обрабатывает отпускание правой конопки мыши }
//#UC START# *48E267150266_4A27A7D5019E_var*
//#UC END# *48E267150266_4A27A7D5019E_var*
begin
//#UC START# *48E267150266_4A27A7D5019E_impl*
Result := false;
//#UC END# *48E267150266_4A27A7D5019E_impl*
end;//TevControlParaHotSpot.RButtonUp
function TevControlParaHotSpot.MButtonDown(const aView: InevControlView;
const Keys: TevMouseState): Boolean;
{* Обрабатывает нажатие колеса мыши }
//#UC START# *49DB4675025E_4A27A7D5019E_var*
//#UC END# *49DB4675025E_4A27A7D5019E_var*
begin
//#UC START# *49DB4675025E_4A27A7D5019E_impl*
Result := False;
//#UC END# *49DB4675025E_4A27A7D5019E_impl*
end;//TevControlParaHotSpot.MButtonDown
function TevControlParaHotSpot.MButtonUp(const aView: InevControlView;
const Keys: TevMouseState): Boolean;
{* Обрабатывает отпускание колеса мыши }
//#UC START# *49DB468302A5_4A27A7D5019E_var*
//#UC END# *49DB468302A5_4A27A7D5019E_var*
begin
//#UC START# *49DB468302A5_4A27A7D5019E_impl*
Result := False;
//#UC END# *49DB468302A5_4A27A7D5019E_impl*
end;//TevControlParaHotSpot.MButtonUp
function TevControlParaHotSpot.CanDrag: Boolean;
//#UC START# *4ECCD6840014_4A27A7D5019E_var*
//#UC END# *4ECCD6840014_4A27A7D5019E_var*
begin
//#UC START# *4ECCD6840014_4A27A7D5019E_impl*
Result := True;
//#UC END# *4ECCD6840014_4A27A7D5019E_impl*
end;//TevControlParaHotSpot.CanDrag
procedure TevControlParaHotSpot.Cleanup;
{* Функция очистки полей объекта. }
//#UC START# *479731C50290_4A27A7D5019E_var*
//#UC END# *479731C50290_4A27A7D5019E_var*
begin
//#UC START# *479731C50290_4A27A7D5019E_impl*
f_ControlFriend := nil;
thisMap := nil;
inherited;
//#UC END# *479731C50290_4A27A7D5019E_impl*
end;//TevControlParaHotSpot.Cleanup
procedure TevControlParaHotSpot.ClearFields;
begin
f_ControlFriend := nil;
inherited;
end;//TevControlParaHotSpot.ClearFields
{$IfEnd} // Defined(evNeedHotSpot)
end.
|
PROGRAM FindLarge;
{ THIS PROGRAM READS IN TWO INTEGERS. IT
WILL DETERMINE WHICH IS THE LARGER OF THE TWO,
AND PRINT AN APPROPRIATE MESSAGE }
VAR Number1: INTEGER ;{FIRST NUMBER READ}
Number2: INTEGER;{SECOND NUMBER READ}
Larger:INTEGER; {THE LARGER ONE}
BEGIN
READ (Number1);
Larger := 1;
IF Number1 < Number2 THEN
BEGIN
Larger := Number1;
END
ELSE
BEGIN
Larger := Number2;
END;
WRITE ('THE LARGER OF ' , Number1,' AND ',Number2,' IS ',Larger );
END.
|
namespace Sugar;
interface
type
{$IF COOPER}
Url = public class mapped to java.net.URL
public
constructor(UriString: String);
property Scheme: String read mapped.Protocol;
property Host: String read mapped.Host;
property Port: Int32 read mapped.Port;
property Path: String read mapped.Path;
property QueryString: String read mapped.Query;
property Fragment: String read mapped.toURI.Fragment;
property UserInfo: String read mapped.UserInfo;
{$ELSEIF ECHOES}
Url = public class mapped to System.Uri
private
method GetPort: Integer;
method GetFragment: String;
method GetUserInfo: String;
method GetQueryString: String;
public
constructor(UriString: String);
property Scheme: String read mapped.Scheme;
property Host: String read mapped.Host;
property Port: Int32 read GetPort;
property Path: String read mapped.AbsolutePath;
property QueryString: String read GetQueryString;
property Fragment: String read GetFragment;
property UserInfo: String read GetUserInfo;
{$ELSEIF TOFFEE}
Url = public class mapped to Foundation.NSURL
private
method GetUserInfo: String;
method GetPort: Integer;
public
constructor(UriString: String);
property Scheme: String read mapped.scheme;
property Host: String read mapped.host;
property Port: Int32 read GetPort;
property Path: String read mapped.path;
property QueryString: String read mapped.query;
property Fragment: String read mapped.fragment;
property UserInfo: String read GetUserInfo;
method description: NSString; override; inline;
{$ENDIF}
class method UrlEncodeString(aString: String): String;
method GetParentUrl(): Url;
method GetSubUrl(aName: String): Url;
end;
implementation
{$IF TOFFEE}
method Url.description: NSString;
begin
exit mapped.absoluteString;
end;
method Url.GetUserInfo: String;
begin
if mapped.user = nil then
exit nil;
if mapped.password <> nil then
exit mapped.user + ":" + mapped.password
else
exit mapped.user;
end;
method Url.GetPort: Integer;
begin
exit if mapped.port = nil then -1 else mapped.port.intValue;
end;
{$ENDIF}
{$IF ECHOES}
method Url.GetPort: Integer;
begin
if mapped.IsDefaultPort then
exit -1;
exit mapped.Port;
end;
method Url.GetFragment: String;
begin
if mapped.Fragment.Length = 0 then
exit nil;
if mapped.Fragment.StartsWith("#") then
exit mapped.Fragment.Substring(1);
exit mapped.Fragment;
end;
method Url.GetQueryString: String;
begin
if mapped.Query.Length = 0 then
exit nil;
if mapped.Query.StartsWith("?") then
exit mapped.Query.Substring(1);
exit mapped.Query;
end;
method Url.GetUserInfo: String;
begin
if mapped.UserInfo.Length = 0 then
exit nil;
exit mapped.UserInfo;
end;
{$ENDIF}
constructor Url(UriString: String);
begin
if String.IsNullOrEmpty(UriString) then
raise new SugarArgumentNullException("UriString");
{$IF COOPER}
exit new java.net.URI(UriString).toURL; //URI performs validation
{$ELSEIF ECHOES}
exit new System.Uri(UriString);
{$ELSEIF TOFFEE}
var Value := Foundation.NSURL.URLWithString(UriString);
if Value = nil then
raise new SugarArgumentException("Url was not in correct format");
var Req := Foundation.NSURLRequest.requestWithURL(Value);
if not Foundation.NSURLConnection.canHandleRequest(Req) then
raise new SugarArgumentException("Url was not in correct format");
exit Value as not nullable;
{$ENDIF}
end;
class method Url.UrlEncodeString(aString: String): String;
begin
{$IF COOPER}
exit java.net.URLEncoder.Encode(aString, 'utf-8');
{$ELSEIF ECHOES}
{$IF WINDOWS_PHONE}
result := System.Net.HttpUtility.UrlEncode(aString);
{$ELSEIF NETFX_CORE}
result := System.Net.WebUtility.UrlEncode(aString);
{$ELSE}
result := System.Web.HttpUtility.UrlEncode(aString);
{$ENDIF}
{$ELSEIF TOFFEE}
result := NSString(aString).stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.alphanumericCharacterSet);
{$ENDIF}
end;
method Url.GetParentUrl(): nullable Url;
begin
if Path = '/' then
result := nil
{$IF COOPER}
else if Path.EndsWith('/') then
result := mapped.toURI.resolve('..').toURL
else
result := mapped.toURI.resolve('.').toURL;
{$ELSEIF ECHOES}
else if Path.EndsWith('/') then
result := new Uri(mapped, '..')
else
result := new Uri(mapped, '.');
{$ELSEIF TOFFEE}
else
result := mapped.URLByDeletingLastPathComponent;
{$ENDIF}
end;
method Url.GetSubUrl(aName: String): Url;
begin
{$IF COOPER}
result := mapped.toURI.resolve(aName).toURL
{$ELSEIF ECHOES}
result := new Uri(mapped, aName);
{$ELSEIF TOFFEE}
result := mapped.URLByAppendingPathComponent(aName);
{$ENDIF}
end;
end. |
unit MenuPrincipal;
interface
uses
Windows, SysUtils, Variants, Classes, Controls, Forms,
Dialogs, ActnList, Menus, ComCtrls, ExtCtrls, DB, StdCtrls, System.Actions,
ZSqlProcessor, sSkinProvider, sSkinManager, ZAbstractRODataset,
ZAbstractDataset, ZDataset, ZAbstractConnection, ZConnection, sMemo,
sListView, sStatusBar, RzTray, RzPanel, RzRadGrp, Vcl.Mask, RzEdit, RzBtnEdt, IniFiles, Vcl.ImgList, Vcl.ToolWin, Data.Bind.EngExt,
Vcl.Bind.DBEngExt, System.Rtti, System.Bindings.Outputs, Vcl.Bind.Editors, Data.Bind.Components;
type
TUPrincipal = class(TForm)
ActionList1: TActionList;
ActSair: TAction;
MainMenu1: TMainMenu;
Arquivo1: TMenuItem;
Adicionarjogo1: TMenuItem;
RemoverJogo1: TMenuItem;
N1: TMenuItem;
Sair1: TMenuItem;
Ajuda1: TMenuItem;
Ajuda2: TMenuItem;
Sobre1: TMenuItem;
ActAddJogo: TAction;
ActRemJogo: TAction;
ActSobre: TAction;
ZconCAT: TZConnection;
ZqryCAT: TZQuery;
Stsbr1: TsStatusBar;
ListView1: TsListView;
Memo1: TsMemo;
ActAjuda: TAction;
Tzproc1: TZSQLProcessor;
DataHora: TTimer;
ToolBar1: TToolBar;
tbBtnSalvar: TToolButton;
ImageList1: TImageList;
procedure ActSairExecute(Sender: TObject);
procedure MfldZqryCATNOMEGetText(Sender: TField; var Text: string; DisplayText: Boolean);
procedure ListView1SelectItem(Sender: TObject; Item: TListItem; Selected: Boolean);
procedure ActSobreExecute(Sender: TObject);
procedure ActAjudaExecute(Sender: TObject);
procedure ActRemJogoExecute(Sender: TObject);
procedure ListView1ColumnClick(Sender: TObject; Column: TListColumn);
procedure ListView1Compare(Sender: TObject; Item1, Item2: TListItem; Data: Integer; var Compare: Integer);
procedure ActAddJogoExecute(Sender: TObject);
procedure CarregaDados;
procedure Memo1Change(Sender: TObject);
procedure ListView1Change(Sender: TObject; Item: TListItem; Change: TItemChange);
procedure DataHoraTimer(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
procedure SalvaDados;
procedure FormKeyPress(Sender: TObject; var Key: Char);
private
// Variaveis para ordenacao de listview
Descending: Boolean;
SortedColumn: Integer;
// Variavel de declaracao de carregamento
cCarregando: Boolean;
bModified: Boolean;
public
end;
var
UPrincipal: TUPrincipal;
implementation
uses ABOUT, UAddJogo;
{$R *.dfm}
procedure TUPrincipal.ActAddJogoExecute(Sender: TObject);
begin
// Mostra tela de about
FrmAddJogo.ShowModal;
end;
procedure TUPrincipal.ActAjudaExecute(Sender: TObject);
begin
// Chama site de ajuda
// ShellExecute(Handle, 'open', 'http://www.google.com.br', '', '', 1);
end;
procedure TUPrincipal.ActRemJogoExecute(Sender: TObject);
var
cIdJogo, Sql: string;
begin
// Remove jogo do banco de dados e recarrega a lista
If ListView1.Selected <> nil then
If Application.MessageBox('Confirma exclusão do jogo?', 'Excluir jogo', mb_iconquestion + mb_yesno) = idYes then
begin
// Pega id do jogo selecionado
cIdJogo := ListView1.Items[ListView1.Selected.Index].Caption;
// Limpa SQL
Tzproc1.Script.Clear;
// Gera SQL para apagar jogo
Tzproc1.Script.Add('UPDATE JOGOS SET D_E_L_E_T_ = "*" WHERE ID = ' + cIdJogo + ' ');
// Executa Sql
Tzproc1.Execute;
// Limpa SQL
Tzproc1.Script.Clear;
// Gera SQL para apagar dicas do jogo
Tzproc1.Script.Add('UPDATE DICAS SET D_E_L_E_T_ = "*" WHERE JOGOID = ' + cIdJogo + ' ');
// Executa Sql
Tzproc1.Execute;
// Limpa barra de Status
Stsbr1.Panels[0].Text := ' ';
// Recarrega dos dados
CarregaDados;
end;
end;
procedure TUPrincipal.ActSairExecute(Sender: TObject);
begin
// Sai do sistema
Close;
end;
procedure TUPrincipal.FormClose(Sender: TObject; var Action: TCloseAction);
var
cIdJogo: string;
// Define variavel do arquivo ini
Ini: TIniFile;
begin
// Define nome do arquivo ini
Ini := TIniFile.Create(ExtractFilePath(Application.ExeName) + 'config.ini');
try
// Grava posição do form
Ini.WriteInteger('Position', 'Top', Top);
Ini.WriteInteger('Position', 'Left', Left);
finally
Ini.Free;
end;
if ListView1.Selected <> nil then
if cCarregando <> True then
if bModified then
If Application.MessageBox('Deseja salvar as alterações', 'Salvar dicas...', mb_iconquestion + mb_yesno) = idYes then
begin
SalvaDados;
end;
end;
procedure TUPrincipal.FormKeyPress(Sender: TObject; var Key: Char);
begin
if (Key = ^S) then
begin
SalvaDados;
Key := #0;
end;
if Key = ^A then
begin
Memo1.SelectAll;
Key := #0;
end;
end;
procedure TUPrincipal.SalvaDados;
var
cIdJogo: string;
begin
if bModified then
begin
// Pega id do jogo selecionado
cIdJogo := ListView1.Items[ListView1.Selected.Index].Caption;
// Faz update nas dicas já existentes para ficarem como deletedas
// Limpa SQL
Tzproc1.Script.Clear;
// Gera SQL para apagar jogo
Tzproc1.Script.Add('UPDATE DICAS SET D_E_L_E_T_ = "*" WHERE JOGOID = ' + cIdJogo + ' ');
// Executa Sql
Tzproc1.Execute;
// Limpa SQL
Tzproc1.Script.Clear;
// Gera SQL para apagar jogo
Tzproc1.Script.Add('INSERT INTO DICAS (TEXTO, JOGOID)');
Tzproc1.Script.Add('VALUES ("' + Memo1.Text + '", "' + cIdJogo + '")');
// Executa Sql
Tzproc1.Execute;
// Define variavel de controle de alterações
bModified := false;
end;
end;
procedure TUPrincipal.FormShow(Sender: TObject);
begin
// Ao gerar o formulario, chama a funcao que popula a listview
CarregaDados;
// Limpa memo
Memo1.Clear;
end;
procedure TUPrincipal.ListView1Change(Sender: TObject; Item: TListItem; Change: TItemChange);
var
cIdJogo: string;
begin
// Verifica se existe jogo selecionado, se nao esta carregando a lista e se o texto foi modificado
if (ListView1.Selected <> nil) and (cCarregando <> True) and (bModified) then
begin
// Apresenta mensagem de confirmação
If Application.MessageBox('Deseja salvar as alterações', 'Salvar dicas...', mb_iconquestion + mb_yesno) = idYes then
begin
// Chama função que faz o salvamento dos dados
SalvaDados;
end;
end;
end;
procedure TUPrincipal.ListView1ColumnClick(Sender: TObject; Column: TListColumn);
begin
// Ordenacao de colunas
TListView(Sender).SortType := stNone;
if Column.Index <> SortedColumn then
begin
SortedColumn := Column.Index;
Descending := false;
end
else
Descending := not Descending;
TListView(Sender).SortType := stText;
end;
procedure TUPrincipal.ListView1Compare(Sender: TObject; Item1, Item2: TListItem; Data: Integer; var Compare: Integer);
begin
// Ordenacao de colunas
if SortedColumn >= 0 then
if SortedColumn = 0 then
Compare := CompareText(Item1.Caption, Item2.Caption)
else
if SortedColumn <> 0 then
Compare := CompareText(Item1.SubItems[SortedColumn - 1], Item2.SubItems[SortedColumn - 1]);
if Descending then
Compare := -Compare;
end;
procedure TUPrincipal.ListView1SelectItem(Sender: TObject; Item: TListItem; Selected: Boolean);
var
// Declara variaveis
cJogo, cIdJogo: string;
i: Integer;
begin
If ListView1.Selected <> nil then
begin
Memo1.ReadOnly := false;
cCarregando := True;
// Pega id do jogo selecionado
cIdJogo := ListView1.Items[ListView1.Selected.Index].Caption;
for i := 0 to ListView1.Items.Count - 1 do
begin
if ListView1.Items[i].Selected then
// Pega nome do jogo selecionado
cJogo := ListView1.Items.Item[i].SubItems[0];
end;
// Apresenta na StatusBar o nome do jogo selecionado.
Stsbr1.Panels[0].Text := 'Jogo selecionado: ' + cJogo;
// Faz select pata pegar dados do jogo
ZqryCAT.Close;
ZqryCAT.Sql.Clear;
ZqryCAT.Sql.Add('SELECT TEXTO AS TEXTO FROM DICAS');
ZqryCAT.Sql.Add('WHERE JOGOID = ' + cIdJogo + ' ');
ZqryCAT.Sql.Add('AND D_E_L_E_T_ = " "');
ZqryCAT.Open;
// Limpa o campo memo
Memo1.Clear;
while not ZqryCAT.Eof do
begin
// Adiciona no memo
Memo1.Lines.Append(ZqryCAT.FieldByName('TEXTO').AsString);
// Vai para o próximo registro
ZqryCAT.Next;
end;
// Fecha area de trabalho
ZqryCAT.Close;
end;
bModified := false;
cCarregando := false;
end;
procedure TUPrincipal.Memo1Change(Sender: TObject);
begin
bModified := True;
end;
procedure TUPrincipal.MfldZqryCATNOMEGetText(Sender: TField; var Text: string; DisplayText: Boolean);
begin
// Mostra texto Memo
Text := Sender.AsString;
end;
procedure TUPrincipal.ActSobreExecute(Sender: TObject);
begin
// Mostra tela de about
AboutBox.ShowModal;
end;
procedure TUPrincipal.CarregaDados;
var
ListItem: TListItem;
begin
cCarregando := True;
ListView1.ShowColumnHeaders := True;
ListView1.Clear;
ZqryCAT.Close;
ZqryCAT.Sql.Clear;
ZqryCAT.Sql.Add('SELECT JG.ID AS ID, JG.NOME AS NOME, CAT.NOME AS CATEGORIA FROM JOGOS JG, CATEGORIAS CAT');
ZqryCAT.Sql.Add('WHERE JG.CATID = CAT.ID');
ZqryCAT.Sql.Add('AND JG.D_E_L_E_T_ = " "');
ZqryCAT.Sql.Add('AND CAT.D_E_L_E_T_ = " "');
ZqryCAT.Sql.Add('ORDER BY JG.NOME');
ZqryCAT.Open;
while not ZqryCAT.Eof do
begin
ListItem := ListView1.Items.Add;
ListItem.Caption := ZqryCAT.FieldByName('ID').AsString;
ListItem.SubItems.Add(ZqryCAT.FieldByName('NOME').AsString);
ListItem.SubItems.Add(ZqryCAT.FieldByName('CATEGORIA').AsString);
ZqryCAT.Next;
end;
ZqryCAT.Close;
// Limpa memo
Memo1.Clear;
cCarregando := false;
bModified := false;
end;
procedure TUPrincipal.DataHoraTimer(Sender: TObject);
begin
// Informa data e hora na barra de status
Stsbr1.Panels[1].Text := ' ' + FormatDateTime('dddd", "dd" de "mmmm" de "yyyy', now);
Stsbr1.Panels[2].Text := ' ' + FormatDateTime('hh:nn:ss', now);
end;
end.
|
unit InfoCLAIMTable;
interface
uses
Classes, DB, DBISAMTb, SysUtils, DBISAMTableAU, DataBuf;
type
TInfoCLAIMRecord = record
PClaimNumber: String[6];
PModCount: Integer;
PPrefix: String[3];
PPolicy: String[7];
PLenderID: String[4];
PName: String[30];
PRcvdDate: String[10];
PLossCode: String[3];
PLossDate: String[10];
PSettMeth: String[4];
PDeniedDate: String[10];
PAppraisedDate: String[10];
PApprRecvDate: String[10];
PStmtYrMo: String[6];
PModYrMo: String[6];
PRepo: Boolean;
PRepoDate: String[10];
PTrackCode: String[2];
PReserve: Currency;
POpen: String[1];
PCollType: String[3];
PUserID: String[6];
PDiary: String[10];
PEntryDate: String[10];
PCompany: String[4];
PLoanNumber: String[18];
PYear: String[4];
PDescription: String[12];
PVIN: String[17];
PExpenseReserve: Currency;
PCatCode: String[3];
PBl_Prefix: String[3];
PBl_Policy: String[7];
PBl_LossDate: String[10];
PBl_LossCode: String[3];
End;
TInfoCLAIMClass2 = class
public
PClaimNumber: String[6];
PModCount: Integer;
PPrefix: String[3];
PPolicy: String[7];
PLenderID: String[4];
PName: String[30];
PRcvdDate: String[10];
PLossCode: String[3];
PLossDate: String[10];
PSettMeth: String[4];
PDeniedDate: String[10];
PAppraisedDate: String[10];
PApprRecvDate: String[10];
PStmtYrMo: String[6];
PModYrMo: String[6];
PRepo: Boolean;
PRepoDate: String[10];
PTrackCode: String[2];
PReserve: Currency;
POpen: String[1];
PCollType: String[3];
PUserID: String[6];
PDiary: String[10];
PEntryDate: String[10];
PCompany: String[4];
PLoanNumber: String[18];
PYear: String[4];
PDescription: String[12];
PVIN: String[17];
PExpenseReserve: Currency;
PCatCode: String[3];
PBl_Prefix: String[3];
PBl_Policy: String[7];
PBl_LossDate: String[10];
PBl_LossCode: String[3];
End;
// function CtoRInfoCLAIM(AClass:TInfoCLAIMClass):TInfoCLAIMRecord;
// procedure RtoCInfoCLAIM(ARecord:TInfoCLAIMRecord;AClass:TInfoCLAIMClass);
TInfoCLAIMBuffer = class(TDataBuf)
protected
function PtrIndex(Index:integer):Pointer;override;
public
Data: TInfoCLAIMRecord;
function FieldNameToIndex(s:string):integer;override;
function FieldType(index:integer):TFieldType;override;
end;
TEIInfoCLAIM = (InfoCLAIMPrimaryKey, InfoCLAIMName, InfoCLAIMPrePol, InfoCLAIMEntry, InfoCLAIMPol, InfoCLAIMLendName, InfoCLAIMLendClaim);
TInfoCLAIMTable = class( TDBISAMTableAU )
private
FDFClaimNumber: TStringField;
FDFModCount: TIntegerField;
FDFPrefix: TStringField;
FDFPolicy: TStringField;
FDFLenderID: TStringField;
FDFName: TStringField;
FDFRcvdDate: TStringField;
FDFLossCode: TStringField;
FDFLossDate: TStringField;
FDFSettMeth: TStringField;
FDFDeniedDate: TStringField;
FDFAppraisedDate: TStringField;
FDFApprRecvDate: TStringField;
FDFStmtYrMo: TStringField;
FDFModYrMo: TStringField;
FDFRepo: TBooleanField;
FDFRepoDate: TStringField;
FDFTrackCode: TStringField;
FDFReserve: TCurrencyField;
FDFOpen: TStringField;
FDFCollType: TStringField;
FDFUserID: TStringField;
FDFDiary: TStringField;
FDFEntryDate: TStringField;
FDFCompany: TStringField;
FDFLoanNumber: TStringField;
FDFYear: TStringField;
FDFDescription: TStringField;
FDFVIN: TStringField;
FDFExpenseReserve: TCurrencyField;
FDFCatCode: TStringField;
FDFBl_Prefix: TStringField;
FDFBl_Policy: TStringField;
FDFBl_LossDate: TStringField;
FDFBl_LossCode: TStringField;
procedure SetPClaimNumber(const Value: String);
function GetPClaimNumber:String;
procedure SetPModCount(const Value: Integer);
function GetPModCount:Integer;
procedure SetPPrefix(const Value: String);
function GetPPrefix:String;
procedure SetPPolicy(const Value: String);
function GetPPolicy:String;
procedure SetPLenderID(const Value: String);
function GetPLenderID:String;
procedure SetPName(const Value: String);
function GetPName:String;
procedure SetPRcvdDate(const Value: String);
function GetPRcvdDate:String;
procedure SetPLossCode(const Value: String);
function GetPLossCode:String;
procedure SetPLossDate(const Value: String);
function GetPLossDate:String;
procedure SetPSettMeth(const Value: String);
function GetPSettMeth:String;
procedure SetPDeniedDate(const Value: String);
function GetPDeniedDate:String;
procedure SetPAppraisedDate(const Value: String);
function GetPAppraisedDate:String;
procedure SetPApprRecvDate(const Value: String);
function GetPApprRecvDate:String;
procedure SetPStmtYrMo(const Value: String);
function GetPStmtYrMo:String;
procedure SetPModYrMo(const Value: String);
function GetPModYrMo:String;
procedure SetPRepo(const Value: Boolean);
function GetPRepo:Boolean;
procedure SetPRepoDate(const Value: String);
function GetPRepoDate:String;
procedure SetPTrackCode(const Value: String);
function GetPTrackCode:String;
procedure SetPReserve(const Value: Currency);
function GetPReserve:Currency;
procedure SetPOpen(const Value: String);
function GetPOpen:String;
procedure SetPCollType(const Value: String);
function GetPCollType:String;
procedure SetPUserID(const Value: String);
function GetPUserID:String;
procedure SetPDiary(const Value: String);
function GetPDiary:String;
procedure SetPEntryDate(const Value: String);
function GetPEntryDate:String;
procedure SetPCompany(const Value: String);
function GetPCompany:String;
procedure SetPLoanNumber(const Value: String);
function GetPLoanNumber:String;
procedure SetPYear(const Value: String);
function GetPYear:String;
procedure SetPDescription(const Value: String);
function GetPDescription:String;
procedure SetPVIN(const Value: String);
function GetPVIN:String;
procedure SetPExpenseReserve(const Value: Currency);
function GetPExpenseReserve:Currency;
procedure SetPCatCode(const Value: String);
function GetPCatCode:String;
procedure SetPBl_Prefix(const Value: String);
function GetPBl_Prefix:String;
procedure SetPBl_Policy(const Value: String);
function GetPBl_Policy:String;
procedure SetPBl_LossDate(const Value: String);
function GetPBl_LossDate:String;
procedure SetPBl_LossCode(const Value: String);
function GetPBl_LossCode:String;
procedure SetEnumIndex(Value: TEIInfoCLAIM);
function GetEnumIndex: TEIInfoCLAIM;
protected
procedure CreateFields; reintroduce;
procedure SetActive(Value: Boolean); override;
procedure LoadFieldDefs(AStringList:TStringList);override;
procedure LoadIndexDefs(AStringList:TStringList);override;
public
function GetDataBuffer:TInfoCLAIMRecord;
procedure StoreDataBuffer(ABuffer:TInfoCLAIMRecord);
property DFClaimNumber: TStringField read FDFClaimNumber;
property DFModCount: TIntegerField read FDFModCount;
property DFPrefix: TStringField read FDFPrefix;
property DFPolicy: TStringField read FDFPolicy;
property DFLenderID: TStringField read FDFLenderID;
property DFName: TStringField read FDFName;
property DFRcvdDate: TStringField read FDFRcvdDate;
property DFLossCode: TStringField read FDFLossCode;
property DFLossDate: TStringField read FDFLossDate;
property DFSettMeth: TStringField read FDFSettMeth;
property DFDeniedDate: TStringField read FDFDeniedDate;
property DFAppraisedDate: TStringField read FDFAppraisedDate;
property DFApprRecvDate: TStringField read FDFApprRecvDate;
property DFStmtYrMo: TStringField read FDFStmtYrMo;
property DFModYrMo: TStringField read FDFModYrMo;
property DFRepo: TBooleanField read FDFRepo;
property DFRepoDate: TStringField read FDFRepoDate;
property DFTrackCode: TStringField read FDFTrackCode;
property DFReserve: TCurrencyField read FDFReserve;
property DFOpen: TStringField read FDFOpen;
property DFCollType: TStringField read FDFCollType;
property DFUserID: TStringField read FDFUserID;
property DFDiary: TStringField read FDFDiary;
property DFEntryDate: TStringField read FDFEntryDate;
property DFCompany: TStringField read FDFCompany;
property DFLoanNumber: TStringField read FDFLoanNumber;
property DFYear: TStringField read FDFYear;
property DFDescription: TStringField read FDFDescription;
property DFVIN: TStringField read FDFVIN;
property DFExpenseReserve: TCurrencyField read FDFExpenseReserve;
property DFCatCode: TStringField read FDFCatCode;
property DFBl_Prefix: TStringField read FDFBl_Prefix;
property DFBl_Policy: TStringField read FDFBl_Policy;
property DFBl_LossDate: TStringField read FDFBl_LossDate;
property DFBl_LossCode: TStringField read FDFBl_LossCode;
property PClaimNumber: String read GetPClaimNumber write SetPClaimNumber;
property PModCount: Integer read GetPModCount write SetPModCount;
property PPrefix: String read GetPPrefix write SetPPrefix;
property PPolicy: String read GetPPolicy write SetPPolicy;
property PLenderID: String read GetPLenderID write SetPLenderID;
property PName: String read GetPName write SetPName;
property PRcvdDate: String read GetPRcvdDate write SetPRcvdDate;
property PLossCode: String read GetPLossCode write SetPLossCode;
property PLossDate: String read GetPLossDate write SetPLossDate;
property PSettMeth: String read GetPSettMeth write SetPSettMeth;
property PDeniedDate: String read GetPDeniedDate write SetPDeniedDate;
property PAppraisedDate: String read GetPAppraisedDate write SetPAppraisedDate;
property PApprRecvDate: String read GetPApprRecvDate write SetPApprRecvDate;
property PStmtYrMo: String read GetPStmtYrMo write SetPStmtYrMo;
property PModYrMo: String read GetPModYrMo write SetPModYrMo;
property PRepo: Boolean read GetPRepo write SetPRepo;
property PRepoDate: String read GetPRepoDate write SetPRepoDate;
property PTrackCode: String read GetPTrackCode write SetPTrackCode;
property PReserve: Currency read GetPReserve write SetPReserve;
property POpen: String read GetPOpen write SetPOpen;
property PCollType: String read GetPCollType write SetPCollType;
property PUserID: String read GetPUserID write SetPUserID;
property PDiary: String read GetPDiary write SetPDiary;
property PEntryDate: String read GetPEntryDate write SetPEntryDate;
property PCompany: String read GetPCompany write SetPCompany;
property PLoanNumber: String read GetPLoanNumber write SetPLoanNumber;
property PYear: String read GetPYear write SetPYear;
property PDescription: String read GetPDescription write SetPDescription;
property PVIN: String read GetPVIN write SetPVIN;
property PExpenseReserve: Currency read GetPExpenseReserve write SetPExpenseReserve;
property PCatCode: String read GetPCatCode write SetPCatCode;
property PBl_Prefix: String read GetPBl_Prefix write SetPBl_Prefix;
property PBl_Policy: String read GetPBl_Policy write SetPBl_Policy;
property PBl_LossDate: String read GetPBl_LossDate write SetPBl_LossDate;
property PBl_LossCode: String read GetPBl_LossCode write SetPBl_LossCode;
published
property Active write SetActive;
property EnumIndex: TEIInfoCLAIM read GetEnumIndex write SetEnumIndex;
end; { TInfoCLAIMTable }
TInfoCLAIMQuery = class( TDBISAMQueryAU )
private
FDFClaimNumber: TStringField;
FDFModCount: TIntegerField;
FDFPrefix: TStringField;
FDFPolicy: TStringField;
FDFLenderID: TStringField;
FDFName: TStringField;
FDFRcvdDate: TStringField;
FDFLossCode: TStringField;
FDFLossDate: TStringField;
FDFSettMeth: TStringField;
FDFDeniedDate: TStringField;
FDFAppraisedDate: TStringField;
FDFApprRecvDate: TStringField;
FDFStmtYrMo: TStringField;
FDFModYrMo: TStringField;
FDFRepo: TBooleanField;
FDFRepoDate: TStringField;
FDFTrackCode: TStringField;
FDFReserve: TCurrencyField;
FDFOpen: TStringField;
FDFCollType: TStringField;
FDFUserID: TStringField;
FDFDiary: TStringField;
FDFEntryDate: TStringField;
FDFCompany: TStringField;
FDFLoanNumber: TStringField;
FDFYear: TStringField;
FDFDescription: TStringField;
FDFVIN: TStringField;
FDFExpenseReserve: TCurrencyField;
FDFCatCode: TStringField;
FDFBl_Prefix: TStringField;
FDFBl_Policy: TStringField;
FDFBl_LossDate: TStringField;
FDFBl_LossCode: TStringField;
procedure SetPClaimNumber(const Value: String);
function GetPClaimNumber:String;
procedure SetPModCount(const Value: Integer);
function GetPModCount:Integer;
procedure SetPPrefix(const Value: String);
function GetPPrefix:String;
procedure SetPPolicy(const Value: String);
function GetPPolicy:String;
procedure SetPLenderID(const Value: String);
function GetPLenderID:String;
procedure SetPName(const Value: String);
function GetPName:String;
procedure SetPRcvdDate(const Value: String);
function GetPRcvdDate:String;
procedure SetPLossCode(const Value: String);
function GetPLossCode:String;
procedure SetPLossDate(const Value: String);
function GetPLossDate:String;
procedure SetPSettMeth(const Value: String);
function GetPSettMeth:String;
procedure SetPDeniedDate(const Value: String);
function GetPDeniedDate:String;
procedure SetPAppraisedDate(const Value: String);
function GetPAppraisedDate:String;
procedure SetPApprRecvDate(const Value: String);
function GetPApprRecvDate:String;
procedure SetPStmtYrMo(const Value: String);
function GetPStmtYrMo:String;
procedure SetPModYrMo(const Value: String);
function GetPModYrMo:String;
procedure SetPRepo(const Value: Boolean);
function GetPRepo:Boolean;
procedure SetPRepoDate(const Value: String);
function GetPRepoDate:String;
procedure SetPTrackCode(const Value: String);
function GetPTrackCode:String;
procedure SetPReserve(const Value: Currency);
function GetPReserve:Currency;
procedure SetPOpen(const Value: String);
function GetPOpen:String;
procedure SetPCollType(const Value: String);
function GetPCollType:String;
procedure SetPUserID(const Value: String);
function GetPUserID:String;
procedure SetPDiary(const Value: String);
function GetPDiary:String;
procedure SetPEntryDate(const Value: String);
function GetPEntryDate:String;
procedure SetPCompany(const Value: String);
function GetPCompany:String;
procedure SetPLoanNumber(const Value: String);
function GetPLoanNumber:String;
procedure SetPYear(const Value: String);
function GetPYear:String;
procedure SetPDescription(const Value: String);
function GetPDescription:String;
procedure SetPVIN(const Value: String);
function GetPVIN:String;
procedure SetPExpenseReserve(const Value: Currency);
function GetPExpenseReserve:Currency;
procedure SetPCatCode(const Value: String);
function GetPCatCode:String;
procedure SetPBl_Prefix(const Value: String);
function GetPBl_Prefix:String;
procedure SetPBl_Policy(const Value: String);
function GetPBl_Policy:String;
procedure SetPBl_LossDate(const Value: String);
function GetPBl_LossDate:String;
procedure SetPBl_LossCode(const Value: String);
function GetPBl_LossCode:String;
protected
procedure CreateFields; reintroduce;
procedure SetActive(Value: Boolean); override;
public
function GetDataBuffer:TInfoCLAIMRecord;
procedure StoreDataBuffer(ABuffer:TInfoCLAIMRecord);
property DFClaimNumber: TStringField read FDFClaimNumber;
property DFModCount: TIntegerField read FDFModCount;
property DFPrefix: TStringField read FDFPrefix;
property DFPolicy: TStringField read FDFPolicy;
property DFLenderID: TStringField read FDFLenderID;
property DFName: TStringField read FDFName;
property DFRcvdDate: TStringField read FDFRcvdDate;
property DFLossCode: TStringField read FDFLossCode;
property DFLossDate: TStringField read FDFLossDate;
property DFSettMeth: TStringField read FDFSettMeth;
property DFDeniedDate: TStringField read FDFDeniedDate;
property DFAppraisedDate: TStringField read FDFAppraisedDate;
property DFApprRecvDate: TStringField read FDFApprRecvDate;
property DFStmtYrMo: TStringField read FDFStmtYrMo;
property DFModYrMo: TStringField read FDFModYrMo;
property DFRepo: TBooleanField read FDFRepo;
property DFRepoDate: TStringField read FDFRepoDate;
property DFTrackCode: TStringField read FDFTrackCode;
property DFReserve: TCurrencyField read FDFReserve;
property DFOpen: TStringField read FDFOpen;
property DFCollType: TStringField read FDFCollType;
property DFUserID: TStringField read FDFUserID;
property DFDiary: TStringField read FDFDiary;
property DFEntryDate: TStringField read FDFEntryDate;
property DFCompany: TStringField read FDFCompany;
property DFLoanNumber: TStringField read FDFLoanNumber;
property DFYear: TStringField read FDFYear;
property DFDescription: TStringField read FDFDescription;
property DFVIN: TStringField read FDFVIN;
property DFExpenseReserve: TCurrencyField read FDFExpenseReserve;
property DFCatCode: TStringField read FDFCatCode;
property DFBl_Prefix: TStringField read FDFBl_Prefix;
property DFBl_Policy: TStringField read FDFBl_Policy;
property DFBl_LossDate: TStringField read FDFBl_LossDate;
property DFBl_LossCode: TStringField read FDFBl_LossCode;
property PClaimNumber: String read GetPClaimNumber write SetPClaimNumber;
property PModCount: Integer read GetPModCount write SetPModCount;
property PPrefix: String read GetPPrefix write SetPPrefix;
property PPolicy: String read GetPPolicy write SetPPolicy;
property PLenderID: String read GetPLenderID write SetPLenderID;
property PName: String read GetPName write SetPName;
property PRcvdDate: String read GetPRcvdDate write SetPRcvdDate;
property PLossCode: String read GetPLossCode write SetPLossCode;
property PLossDate: String read GetPLossDate write SetPLossDate;
property PSettMeth: String read GetPSettMeth write SetPSettMeth;
property PDeniedDate: String read GetPDeniedDate write SetPDeniedDate;
property PAppraisedDate: String read GetPAppraisedDate write SetPAppraisedDate;
property PApprRecvDate: String read GetPApprRecvDate write SetPApprRecvDate;
property PStmtYrMo: String read GetPStmtYrMo write SetPStmtYrMo;
property PModYrMo: String read GetPModYrMo write SetPModYrMo;
property PRepo: Boolean read GetPRepo write SetPRepo;
property PRepoDate: String read GetPRepoDate write SetPRepoDate;
property PTrackCode: String read GetPTrackCode write SetPTrackCode;
property PReserve: Currency read GetPReserve write SetPReserve;
property POpen: String read GetPOpen write SetPOpen;
property PCollType: String read GetPCollType write SetPCollType;
property PUserID: String read GetPUserID write SetPUserID;
property PDiary: String read GetPDiary write SetPDiary;
property PEntryDate: String read GetPEntryDate write SetPEntryDate;
property PCompany: String read GetPCompany write SetPCompany;
property PLoanNumber: String read GetPLoanNumber write SetPLoanNumber;
property PYear: String read GetPYear write SetPYear;
property PDescription: String read GetPDescription write SetPDescription;
property PVIN: String read GetPVIN write SetPVIN;
property PExpenseReserve: Currency read GetPExpenseReserve write SetPExpenseReserve;
property PCatCode: String read GetPCatCode write SetPCatCode;
property PBl_Prefix: String read GetPBl_Prefix write SetPBl_Prefix;
property PBl_Policy: String read GetPBl_Policy write SetPBl_Policy;
property PBl_LossDate: String read GetPBl_LossDate write SetPBl_LossDate;
property PBl_LossCode: String read GetPBl_LossCode write SetPBl_LossCode;
published
property Active write SetActive;
end; { TInfoCLAIMTable }
procedure Register;
implementation
procedure TInfoCLAIMTable.CreateFields;
begin
FDFClaimNumber := CreateField( 'ClaimNumber' ) as TStringField;
FDFModCount := CreateField( 'ModCount' ) as TIntegerField;
FDFPrefix := CreateField( 'Prefix' ) as TStringField;
FDFPolicy := CreateField( 'Policy' ) as TStringField;
FDFLenderID := CreateField( 'LenderID' ) as TStringField;
FDFName := CreateField( 'Name' ) as TStringField;
FDFRcvdDate := CreateField( 'RcvdDate' ) as TStringField;
FDFLossCode := CreateField( 'LossCode' ) as TStringField;
FDFLossDate := CreateField( 'LossDate' ) as TStringField;
FDFSettMeth := CreateField( 'SettMeth' ) as TStringField;
FDFDeniedDate := CreateField( 'DeniedDate' ) as TStringField;
FDFAppraisedDate := CreateField( 'AppraisedDate' ) as TStringField;
FDFApprRecvDate := CreateField( 'ApprRecvDate' ) as TStringField;
FDFStmtYrMo := CreateField( 'StmtYrMo' ) as TStringField;
FDFModYrMo := CreateField( 'ModYrMo' ) as TStringField;
FDFRepo := CreateField( 'Repo' ) as TBooleanField;
FDFRepoDate := CreateField( 'RepoDate' ) as TStringField;
FDFTrackCode := CreateField( 'TrackCode' ) as TStringField;
FDFReserve := CreateField( 'Reserve' ) as TCurrencyField;
FDFOpen := CreateField( 'Open' ) as TStringField;
FDFCollType := CreateField( 'CollType' ) as TStringField;
FDFUserID := CreateField( 'UserID' ) as TStringField;
FDFDiary := CreateField( 'Diary' ) as TStringField;
FDFEntryDate := CreateField( 'EntryDate' ) as TStringField;
FDFCompany := CreateField( 'Company' ) as TStringField;
FDFLoanNumber := CreateField( 'LoanNumber' ) as TStringField;
FDFYear := CreateField( 'Year' ) as TStringField;
FDFDescription := CreateField( 'Description' ) as TStringField;
FDFVIN := CreateField( 'VIN' ) as TStringField;
FDFExpenseReserve := CreateField( 'ExpenseReserve' ) as TCurrencyField;
FDFCatCode := CreateField( 'CatCode' ) as TStringField;
FDFBl_Prefix := CreateField( 'Bl_Prefix' ) as TStringField;
FDFBl_Policy := CreateField( 'Bl_Policy' ) as TStringField;
FDFBl_LossDate := CreateField( 'Bl_LossDate' ) as TStringField;
FDFBl_LossCode := CreateField( 'Bl_LossCode' ) as TStringField;
end; { TInfoCLAIMTable.CreateFields }
procedure TInfoCLAIMTable.SetActive(Value: Boolean);
begin
inherited SetActive(Value);
if Active then
CreateFields;
end; { TInfoCLAIMTable.SetActive }
procedure TInfoCLAIMTable.SetPClaimNumber(const Value: String);
begin
DFClaimNumber.Value := Value;
end;
function TInfoCLAIMTable.GetPClaimNumber:String;
begin
result := DFClaimNumber.Value;
end;
procedure TInfoCLAIMTable.SetPModCount(const Value: Integer);
begin
DFModCount.Value := Value;
end;
function TInfoCLAIMTable.GetPModCount:Integer;
begin
result := DFModCount.Value;
end;
procedure TInfoCLAIMTable.SetPPrefix(const Value: String);
begin
DFPrefix.Value := Value;
end;
function TInfoCLAIMTable.GetPPrefix:String;
begin
result := DFPrefix.Value;
end;
procedure TInfoCLAIMTable.SetPPolicy(const Value: String);
begin
DFPolicy.Value := Value;
end;
function TInfoCLAIMTable.GetPPolicy:String;
begin
result := DFPolicy.Value;
end;
procedure TInfoCLAIMTable.SetPLenderID(const Value: String);
begin
DFLenderID.Value := Value;
end;
function TInfoCLAIMTable.GetPLenderID:String;
begin
result := DFLenderID.Value;
end;
procedure TInfoCLAIMTable.SetPName(const Value: String);
begin
DFName.Value := Value;
end;
function TInfoCLAIMTable.GetPName:String;
begin
result := DFName.Value;
end;
procedure TInfoCLAIMTable.SetPRcvdDate(const Value: String);
begin
DFRcvdDate.Value := Value;
end;
function TInfoCLAIMTable.GetPRcvdDate:String;
begin
result := DFRcvdDate.Value;
end;
procedure TInfoCLAIMTable.SetPLossCode(const Value: String);
begin
DFLossCode.Value := Value;
end;
function TInfoCLAIMTable.GetPLossCode:String;
begin
result := DFLossCode.Value;
end;
procedure TInfoCLAIMTable.SetPLossDate(const Value: String);
begin
DFLossDate.Value := Value;
end;
function TInfoCLAIMTable.GetPLossDate:String;
begin
result := DFLossDate.Value;
end;
procedure TInfoCLAIMTable.SetPSettMeth(const Value: String);
begin
DFSettMeth.Value := Value;
end;
function TInfoCLAIMTable.GetPSettMeth:String;
begin
result := DFSettMeth.Value;
end;
procedure TInfoCLAIMTable.SetPDeniedDate(const Value: String);
begin
DFDeniedDate.Value := Value;
end;
function TInfoCLAIMTable.GetPDeniedDate:String;
begin
result := DFDeniedDate.Value;
end;
procedure TInfoCLAIMTable.SetPAppraisedDate(const Value: String);
begin
DFAppraisedDate.Value := Value;
end;
function TInfoCLAIMTable.GetPAppraisedDate:String;
begin
result := DFAppraisedDate.Value;
end;
procedure TInfoCLAIMTable.SetPApprRecvDate(const Value: String);
begin
DFApprRecvDate.Value := Value;
end;
function TInfoCLAIMTable.GetPApprRecvDate:String;
begin
result := DFApprRecvDate.Value;
end;
procedure TInfoCLAIMTable.SetPStmtYrMo(const Value: String);
begin
DFStmtYrMo.Value := Value;
end;
function TInfoCLAIMTable.GetPStmtYrMo:String;
begin
result := DFStmtYrMo.Value;
end;
procedure TInfoCLAIMTable.SetPModYrMo(const Value: String);
begin
DFModYrMo.Value := Value;
end;
function TInfoCLAIMTable.GetPModYrMo:String;
begin
result := DFModYrMo.Value;
end;
procedure TInfoCLAIMTable.SetPRepo(const Value: Boolean);
begin
DFRepo.Value := Value;
end;
function TInfoCLAIMTable.GetPRepo:Boolean;
begin
result := DFRepo.Value;
end;
procedure TInfoCLAIMTable.SetPRepoDate(const Value: String);
begin
DFRepoDate.Value := Value;
end;
function TInfoCLAIMTable.GetPRepoDate:String;
begin
result := DFRepoDate.Value;
end;
procedure TInfoCLAIMTable.SetPTrackCode(const Value: String);
begin
DFTrackCode.Value := Value;
end;
function TInfoCLAIMTable.GetPTrackCode:String;
begin
result := DFTrackCode.Value;
end;
procedure TInfoCLAIMTable.SetPReserve(const Value: Currency);
begin
DFReserve.Value := Value;
end;
function TInfoCLAIMTable.GetPReserve:Currency;
begin
result := DFReserve.Value;
end;
procedure TInfoCLAIMTable.SetPOpen(const Value: String);
begin
DFOpen.Value := Value;
end;
function TInfoCLAIMTable.GetPOpen:String;
begin
result := DFOpen.Value;
end;
procedure TInfoCLAIMTable.SetPCollType(const Value: String);
begin
DFCollType.Value := Value;
end;
function TInfoCLAIMTable.GetPCollType:String;
begin
result := DFCollType.Value;
end;
procedure TInfoCLAIMTable.SetPUserID(const Value: String);
begin
DFUserID.Value := Value;
end;
function TInfoCLAIMTable.GetPUserID:String;
begin
result := DFUserID.Value;
end;
procedure TInfoCLAIMTable.SetPDiary(const Value: String);
begin
DFDiary.Value := Value;
end;
function TInfoCLAIMTable.GetPDiary:String;
begin
result := DFDiary.Value;
end;
procedure TInfoCLAIMTable.SetPEntryDate(const Value: String);
begin
DFEntryDate.Value := Value;
end;
function TInfoCLAIMTable.GetPEntryDate:String;
begin
result := DFEntryDate.Value;
end;
procedure TInfoCLAIMTable.SetPCompany(const Value: String);
begin
DFCompany.Value := Value;
end;
function TInfoCLAIMTable.GetPCompany:String;
begin
result := DFCompany.Value;
end;
procedure TInfoCLAIMTable.SetPLoanNumber(const Value: String);
begin
DFLoanNumber.Value := Value;
end;
function TInfoCLAIMTable.GetPLoanNumber:String;
begin
result := DFLoanNumber.Value;
end;
procedure TInfoCLAIMTable.SetPYear(const Value: String);
begin
DFYear.Value := Value;
end;
function TInfoCLAIMTable.GetPYear:String;
begin
result := DFYear.Value;
end;
procedure TInfoCLAIMTable.SetPDescription(const Value: String);
begin
DFDescription.Value := Value;
end;
function TInfoCLAIMTable.GetPDescription:String;
begin
result := DFDescription.Value;
end;
procedure TInfoCLAIMTable.SetPVIN(const Value: String);
begin
DFVIN.Value := Value;
end;
function TInfoCLAIMTable.GetPVIN:String;
begin
result := DFVIN.Value;
end;
procedure TInfoCLAIMTable.SetPExpenseReserve(const Value: Currency);
begin
DFExpenseReserve.Value := Value;
end;
function TInfoCLAIMTable.GetPExpenseReserve:Currency;
begin
result := DFExpenseReserve.Value;
end;
procedure TInfoCLAIMTable.SetPCatCode(const Value: String);
begin
DFCatCode.Value := Value;
end;
function TInfoCLAIMTable.GetPCatCode:String;
begin
result := DFCatCode.Value;
end;
procedure TInfoCLAIMTable.SetPBl_Prefix(const Value: String);
begin
DFBl_Prefix.Value := Value;
end;
function TInfoCLAIMTable.GetPBl_Prefix:String;
begin
result := DFBl_Prefix.Value;
end;
procedure TInfoCLAIMTable.SetPBl_Policy(const Value: String);
begin
DFBl_Policy.Value := Value;
end;
function TInfoCLAIMTable.GetPBl_Policy:String;
begin
result := DFBl_Policy.Value;
end;
procedure TInfoCLAIMTable.SetPBl_LossDate(const Value: String);
begin
DFBl_LossDate.Value := Value;
end;
function TInfoCLAIMTable.GetPBl_LossDate:String;
begin
result := DFBl_LossDate.Value;
end;
procedure TInfoCLAIMTable.SetPBl_LossCode(const Value: String);
begin
DFBl_LossCode.Value := Value;
end;
function TInfoCLAIMTable.GetPBl_LossCode:String;
begin
result := DFBl_LossCode.Value;
end;
procedure TInfoCLAIMTable.LoadFieldDefs(AStringList: TStringList);
begin
inherited;
with AstringList do
begin
Add('ClaimNumber, String, 6, N');
Add('ModCount, Integer, 0, N');
Add('Prefix, String, 3, N');
Add('Policy, String, 7, N');
Add('LenderID, String, 4, N');
Add('Name, String, 30, N');
Add('RcvdDate, String, 10, N');
Add('LossCode, String, 3, N');
Add('LossDate, String, 10, N');
Add('SettMeth, String, 4, N');
Add('DeniedDate, String, 10, N');
Add('AppraisedDate, String, 10, N');
Add('ApprRecvDate, String, 10, N');
Add('StmtYrMo, String, 6, N');
Add('ModYrMo, String, 6, N');
Add('Repo, Boolean, 0, N');
Add('RepoDate, String, 10, N');
Add('TrackCode, String, 2, N');
Add('Reserve, Currency, 0, N');
Add('Open, String, 1, N');
Add('CollType, String, 3, N');
Add('UserID, String, 6, N');
Add('Diary, String, 10, N');
Add('EntryDate, String, 10, N');
Add('Company, String, 4, N');
Add('LoanNumber, String, 18, N');
Add('Year, String, 4, N');
Add('Description, String, 12, N');
Add('VIN, String, 17, N');
Add('ExpenseReserve, Currency, 0, N');
Add('CatCode, String, 3, N');
Add('Bl_Prefix, String, 3, N');
Add('Bl_Policy, String, 7, N');
Add('Bl_LossDate, String, 10, N');
Add('Bl_LossCode, String, 3, N');
end;
end;
procedure TInfoCLAIMTable.LoadIndexDefs(AStringList: TStringList);
begin
inherited;
with AstringList do
begin
Add('PrimaryKey, ClaimNumber, Y, Y, N, N');
Add('Name, Name, N, N, Y, N');
Add('PrePol, Prefix;Policy, N, N, Y, N');
Add('Entry, EntryDate;ClaimNumber, N, N, Y, N');
Add('Pol, LenderID;Prefix;Policy, N, N, Y, N');
Add('LendName, LenderID;Name, N, N, Y, N');
Add('LendClaim, LenderID;ClaimNumber, N, N, N, N');
end;
end;
procedure TInfoCLAIMTable.SetEnumIndex(Value: TEIInfoCLAIM);
begin
case Value of
InfoCLAIMPrimaryKey : IndexName := '';
InfoCLAIMName : IndexName := 'Name';
InfoCLAIMPrePol : IndexName := 'PrePol';
InfoCLAIMEntry : IndexName := 'Entry';
InfoCLAIMPol : IndexName := 'Pol';
InfoCLAIMLendName : IndexName := 'LendName';
InfoCLAIMLendClaim : IndexName := 'LendClaim';
end;
end;
function TInfoCLAIMTable.GetDataBuffer:TInfoCLAIMRecord;
var buf: TInfoCLAIMRecord;
begin
fillchar(buf, sizeof(buf), 0);
buf.PClaimNumber := DFClaimNumber.Value;
buf.PModCount := DFModCount.Value;
buf.PPrefix := DFPrefix.Value;
buf.PPolicy := DFPolicy.Value;
buf.PLenderID := DFLenderID.Value;
buf.PName := DFName.Value;
buf.PRcvdDate := DFRcvdDate.Value;
buf.PLossCode := DFLossCode.Value;
buf.PLossDate := DFLossDate.Value;
buf.PSettMeth := DFSettMeth.Value;
buf.PDeniedDate := DFDeniedDate.Value;
buf.PAppraisedDate := DFAppraisedDate.Value;
buf.PApprRecvDate := DFApprRecvDate.Value;
buf.PStmtYrMo := DFStmtYrMo.Value;
buf.PModYrMo := DFModYrMo.Value;
buf.PRepo := DFRepo.Value;
buf.PRepoDate := DFRepoDate.Value;
buf.PTrackCode := DFTrackCode.Value;
buf.PReserve := DFReserve.Value;
buf.POpen := DFOpen.Value;
buf.PCollType := DFCollType.Value;
buf.PUserID := DFUserID.Value;
buf.PDiary := DFDiary.Value;
buf.PEntryDate := DFEntryDate.Value;
buf.PCompany := DFCompany.Value;
buf.PLoanNumber := DFLoanNumber.Value;
buf.PYear := DFYear.Value;
buf.PDescription := DFDescription.Value;
buf.PVIN := DFVIN.Value;
buf.PExpenseReserve := DFExpenseReserve.Value;
buf.PCatCode := DFCatCode.Value;
buf.PBl_Prefix := DFBl_Prefix.Value;
buf.PBl_Policy := DFBl_Policy.Value;
buf.PBl_LossDate := DFBl_LossDate.Value;
buf.PBl_LossCode := DFBl_LossCode.Value;
result := buf;
end;
procedure TInfoCLAIMTable.StoreDataBuffer(ABuffer:TInfoCLAIMRecord);
begin
DFClaimNumber.Value := ABuffer.PClaimNumber;
DFModCount.Value := ABuffer.PModCount;
DFPrefix.Value := ABuffer.PPrefix;
DFPolicy.Value := ABuffer.PPolicy;
DFLenderID.Value := ABuffer.PLenderID;
DFName.Value := ABuffer.PName;
DFRcvdDate.Value := ABuffer.PRcvdDate;
DFLossCode.Value := ABuffer.PLossCode;
DFLossDate.Value := ABuffer.PLossDate;
DFSettMeth.Value := ABuffer.PSettMeth;
DFDeniedDate.Value := ABuffer.PDeniedDate;
DFAppraisedDate.Value := ABuffer.PAppraisedDate;
DFApprRecvDate.Value := ABuffer.PApprRecvDate;
DFStmtYrMo.Value := ABuffer.PStmtYrMo;
DFModYrMo.Value := ABuffer.PModYrMo;
DFRepo.Value := ABuffer.PRepo;
DFRepoDate.Value := ABuffer.PRepoDate;
DFTrackCode.Value := ABuffer.PTrackCode;
DFReserve.Value := ABuffer.PReserve;
DFOpen.Value := ABuffer.POpen;
DFCollType.Value := ABuffer.PCollType;
DFUserID.Value := ABuffer.PUserID;
DFDiary.Value := ABuffer.PDiary;
DFEntryDate.Value := ABuffer.PEntryDate;
DFCompany.Value := ABuffer.PCompany;
DFLoanNumber.Value := ABuffer.PLoanNumber;
DFYear.Value := ABuffer.PYear;
DFDescription.Value := ABuffer.PDescription;
DFVIN.Value := ABuffer.PVIN;
DFExpenseReserve.Value := ABuffer.PExpenseReserve;
DFCatCode.Value := ABuffer.PCatCode;
DFBl_Prefix.Value := ABuffer.PBl_Prefix;
DFBl_Policy.Value := ABuffer.PBl_Policy;
DFBl_LossDate.Value := ABuffer.PBl_LossDate;
DFBl_LossCode.Value := ABuffer.PBl_LossCode;
end;
function TInfoCLAIMTable.GetEnumIndex: TEIInfoCLAIM;
var iname : string;
begin
result := InfoCLAIMPrimaryKey;
iname := uppercase(indexname);
if iname = '' then result := InfoCLAIMPrimaryKey;
if iname = 'NAME' then result := InfoCLAIMName;
if iname = 'PREPOL' then result := InfoCLAIMPrePol;
if iname = 'ENTRY' then result := InfoCLAIMEntry;
if iname = 'POL' then result := InfoCLAIMPol;
if iname = 'LENDNAME' then result := InfoCLAIMLendName;
if iname = 'LENDCLAIM' then result := InfoCLAIMLendClaim;
end;
procedure TInfoCLAIMQuery.CreateFields;
begin
FDFClaimNumber := CreateField( 'ClaimNumber' ) as TStringField;
FDFModCount := CreateField( 'ModCount' ) as TIntegerField;
FDFPrefix := CreateField( 'Prefix' ) as TStringField;
FDFPolicy := CreateField( 'Policy' ) as TStringField;
FDFLenderID := CreateField( 'LenderID' ) as TStringField;
FDFName := CreateField( 'Name' ) as TStringField;
FDFRcvdDate := CreateField( 'RcvdDate' ) as TStringField;
FDFLossCode := CreateField( 'LossCode' ) as TStringField;
FDFLossDate := CreateField( 'LossDate' ) as TStringField;
FDFSettMeth := CreateField( 'SettMeth' ) as TStringField;
FDFDeniedDate := CreateField( 'DeniedDate' ) as TStringField;
FDFAppraisedDate := CreateField( 'AppraisedDate' ) as TStringField;
FDFApprRecvDate := CreateField( 'ApprRecvDate' ) as TStringField;
FDFStmtYrMo := CreateField( 'StmtYrMo' ) as TStringField;
FDFModYrMo := CreateField( 'ModYrMo' ) as TStringField;
FDFRepo := CreateField( 'Repo' ) as TBooleanField;
FDFRepoDate := CreateField( 'RepoDate' ) as TStringField;
FDFTrackCode := CreateField( 'TrackCode' ) as TStringField;
FDFReserve := CreateField( 'Reserve' ) as TCurrencyField;
FDFOpen := CreateField( 'Open' ) as TStringField;
FDFCollType := CreateField( 'CollType' ) as TStringField;
FDFUserID := CreateField( 'UserID' ) as TStringField;
FDFDiary := CreateField( 'Diary' ) as TStringField;
FDFEntryDate := CreateField( 'EntryDate' ) as TStringField;
FDFCompany := CreateField( 'Company' ) as TStringField;
FDFLoanNumber := CreateField( 'LoanNumber' ) as TStringField;
FDFYear := CreateField( 'Year' ) as TStringField;
FDFDescription := CreateField( 'Description' ) as TStringField;
FDFVIN := CreateField( 'VIN' ) as TStringField;
FDFExpenseReserve := CreateField( 'ExpenseReserve' ) as TCurrencyField;
FDFCatCode := CreateField( 'CatCode' ) as TStringField;
FDFBl_Prefix := CreateField( 'Bl_Prefix' ) as TStringField;
FDFBl_Policy := CreateField( 'Bl_Policy' ) as TStringField;
FDFBl_LossDate := CreateField( 'Bl_LossDate' ) as TStringField;
FDFBl_LossCode := CreateField( 'Bl_LossCode' ) as TStringField;
end; { TInfoCLAIMQuery.CreateFields }
procedure TInfoCLAIMQuery.SetActive(Value: Boolean);
begin
inherited SetActive(Value);
if Active then
CreateFields;
end; { TInfoCLAIMQuery.SetActive }
procedure TInfoCLAIMQuery.SetPClaimNumber(const Value: String);
begin
DFClaimNumber.Value := Value;
end;
function TInfoCLAIMQuery.GetPClaimNumber:String;
begin
result := DFClaimNumber.Value;
end;
procedure TInfoCLAIMQuery.SetPModCount(const Value: Integer);
begin
DFModCount.Value := Value;
end;
function TInfoCLAIMQuery.GetPModCount:Integer;
begin
result := DFModCount.Value;
end;
procedure TInfoCLAIMQuery.SetPPrefix(const Value: String);
begin
DFPrefix.Value := Value;
end;
function TInfoCLAIMQuery.GetPPrefix:String;
begin
result := DFPrefix.Value;
end;
procedure TInfoCLAIMQuery.SetPPolicy(const Value: String);
begin
DFPolicy.Value := Value;
end;
function TInfoCLAIMQuery.GetPPolicy:String;
begin
result := DFPolicy.Value;
end;
procedure TInfoCLAIMQuery.SetPLenderID(const Value: String);
begin
DFLenderID.Value := Value;
end;
function TInfoCLAIMQuery.GetPLenderID:String;
begin
result := DFLenderID.Value;
end;
procedure TInfoCLAIMQuery.SetPName(const Value: String);
begin
DFName.Value := Value;
end;
function TInfoCLAIMQuery.GetPName:String;
begin
result := DFName.Value;
end;
procedure TInfoCLAIMQuery.SetPRcvdDate(const Value: String);
begin
DFRcvdDate.Value := Value;
end;
function TInfoCLAIMQuery.GetPRcvdDate:String;
begin
result := DFRcvdDate.Value;
end;
procedure TInfoCLAIMQuery.SetPLossCode(const Value: String);
begin
DFLossCode.Value := Value;
end;
function TInfoCLAIMQuery.GetPLossCode:String;
begin
result := DFLossCode.Value;
end;
procedure TInfoCLAIMQuery.SetPLossDate(const Value: String);
begin
DFLossDate.Value := Value;
end;
function TInfoCLAIMQuery.GetPLossDate:String;
begin
result := DFLossDate.Value;
end;
procedure TInfoCLAIMQuery.SetPSettMeth(const Value: String);
begin
DFSettMeth.Value := Value;
end;
function TInfoCLAIMQuery.GetPSettMeth:String;
begin
result := DFSettMeth.Value;
end;
procedure TInfoCLAIMQuery.SetPDeniedDate(const Value: String);
begin
DFDeniedDate.Value := Value;
end;
function TInfoCLAIMQuery.GetPDeniedDate:String;
begin
result := DFDeniedDate.Value;
end;
procedure TInfoCLAIMQuery.SetPAppraisedDate(const Value: String);
begin
DFAppraisedDate.Value := Value;
end;
function TInfoCLAIMQuery.GetPAppraisedDate:String;
begin
result := DFAppraisedDate.Value;
end;
procedure TInfoCLAIMQuery.SetPApprRecvDate(const Value: String);
begin
DFApprRecvDate.Value := Value;
end;
function TInfoCLAIMQuery.GetPApprRecvDate:String;
begin
result := DFApprRecvDate.Value;
end;
procedure TInfoCLAIMQuery.SetPStmtYrMo(const Value: String);
begin
DFStmtYrMo.Value := Value;
end;
function TInfoCLAIMQuery.GetPStmtYrMo:String;
begin
result := DFStmtYrMo.Value;
end;
procedure TInfoCLAIMQuery.SetPModYrMo(const Value: String);
begin
DFModYrMo.Value := Value;
end;
function TInfoCLAIMQuery.GetPModYrMo:String;
begin
result := DFModYrMo.Value;
end;
procedure TInfoCLAIMQuery.SetPRepo(const Value: Boolean);
begin
DFRepo.Value := Value;
end;
function TInfoCLAIMQuery.GetPRepo:Boolean;
begin
result := DFRepo.Value;
end;
procedure TInfoCLAIMQuery.SetPRepoDate(const Value: String);
begin
DFRepoDate.Value := Value;
end;
function TInfoCLAIMQuery.GetPRepoDate:String;
begin
result := DFRepoDate.Value;
end;
procedure TInfoCLAIMQuery.SetPTrackCode(const Value: String);
begin
DFTrackCode.Value := Value;
end;
function TInfoCLAIMQuery.GetPTrackCode:String;
begin
result := DFTrackCode.Value;
end;
procedure TInfoCLAIMQuery.SetPReserve(const Value: Currency);
begin
DFReserve.Value := Value;
end;
function TInfoCLAIMQuery.GetPReserve:Currency;
begin
result := DFReserve.Value;
end;
procedure TInfoCLAIMQuery.SetPOpen(const Value: String);
begin
DFOpen.Value := Value;
end;
function TInfoCLAIMQuery.GetPOpen:String;
begin
result := DFOpen.Value;
end;
procedure TInfoCLAIMQuery.SetPCollType(const Value: String);
begin
DFCollType.Value := Value;
end;
function TInfoCLAIMQuery.GetPCollType:String;
begin
result := DFCollType.Value;
end;
procedure TInfoCLAIMQuery.SetPUserID(const Value: String);
begin
DFUserID.Value := Value;
end;
function TInfoCLAIMQuery.GetPUserID:String;
begin
result := DFUserID.Value;
end;
procedure TInfoCLAIMQuery.SetPDiary(const Value: String);
begin
DFDiary.Value := Value;
end;
function TInfoCLAIMQuery.GetPDiary:String;
begin
result := DFDiary.Value;
end;
procedure TInfoCLAIMQuery.SetPEntryDate(const Value: String);
begin
DFEntryDate.Value := Value;
end;
function TInfoCLAIMQuery.GetPEntryDate:String;
begin
result := DFEntryDate.Value;
end;
procedure TInfoCLAIMQuery.SetPCompany(const Value: String);
begin
DFCompany.Value := Value;
end;
function TInfoCLAIMQuery.GetPCompany:String;
begin
result := DFCompany.Value;
end;
procedure TInfoCLAIMQuery.SetPLoanNumber(const Value: String);
begin
DFLoanNumber.Value := Value;
end;
function TInfoCLAIMQuery.GetPLoanNumber:String;
begin
result := DFLoanNumber.Value;
end;
procedure TInfoCLAIMQuery.SetPYear(const Value: String);
begin
DFYear.Value := Value;
end;
function TInfoCLAIMQuery.GetPYear:String;
begin
result := DFYear.Value;
end;
procedure TInfoCLAIMQuery.SetPDescription(const Value: String);
begin
DFDescription.Value := Value;
end;
function TInfoCLAIMQuery.GetPDescription:String;
begin
result := DFDescription.Value;
end;
procedure TInfoCLAIMQuery.SetPVIN(const Value: String);
begin
DFVIN.Value := Value;
end;
function TInfoCLAIMQuery.GetPVIN:String;
begin
result := DFVIN.Value;
end;
procedure TInfoCLAIMQuery.SetPExpenseReserve(const Value: Currency);
begin
DFExpenseReserve.Value := Value;
end;
function TInfoCLAIMQuery.GetPExpenseReserve:Currency;
begin
result := DFExpenseReserve.Value;
end;
procedure TInfoCLAIMQuery.SetPCatCode(const Value: String);
begin
DFCatCode.Value := Value;
end;
function TInfoCLAIMQuery.GetPCatCode:String;
begin
result := DFCatCode.Value;
end;
procedure TInfoCLAIMQuery.SetPBl_Prefix(const Value: String);
begin
DFBl_Prefix.Value := Value;
end;
function TInfoCLAIMQuery.GetPBl_Prefix:String;
begin
result := DFBl_Prefix.Value;
end;
procedure TInfoCLAIMQuery.SetPBl_Policy(const Value: String);
begin
DFBl_Policy.Value := Value;
end;
function TInfoCLAIMQuery.GetPBl_Policy:String;
begin
result := DFBl_Policy.Value;
end;
procedure TInfoCLAIMQuery.SetPBl_LossDate(const Value: String);
begin
DFBl_LossDate.Value := Value;
end;
function TInfoCLAIMQuery.GetPBl_LossDate:String;
begin
result := DFBl_LossDate.Value;
end;
procedure TInfoCLAIMQuery.SetPBl_LossCode(const Value: String);
begin
DFBl_LossCode.Value := Value;
end;
function TInfoCLAIMQuery.GetPBl_LossCode:String;
begin
result := DFBl_LossCode.Value;
end;
function TInfoCLAIMQuery.GetDataBuffer:TInfoCLAIMRecord;
var buf: TInfoCLAIMRecord;
begin
fillchar(buf, sizeof(buf), 0);
buf.PClaimNumber := DFClaimNumber.Value;
buf.PModCount := DFModCount.Value;
buf.PPrefix := DFPrefix.Value;
buf.PPolicy := DFPolicy.Value;
buf.PLenderID := DFLenderID.Value;
buf.PName := DFName.Value;
buf.PRcvdDate := DFRcvdDate.Value;
buf.PLossCode := DFLossCode.Value;
buf.PLossDate := DFLossDate.Value;
buf.PSettMeth := DFSettMeth.Value;
buf.PDeniedDate := DFDeniedDate.Value;
buf.PAppraisedDate := DFAppraisedDate.Value;
buf.PApprRecvDate := DFApprRecvDate.Value;
buf.PStmtYrMo := DFStmtYrMo.Value;
buf.PModYrMo := DFModYrMo.Value;
buf.PRepo := DFRepo.Value;
buf.PRepoDate := DFRepoDate.Value;
buf.PTrackCode := DFTrackCode.Value;
buf.PReserve := DFReserve.Value;
buf.POpen := DFOpen.Value;
buf.PCollType := DFCollType.Value;
buf.PUserID := DFUserID.Value;
buf.PDiary := DFDiary.Value;
buf.PEntryDate := DFEntryDate.Value;
buf.PCompany := DFCompany.Value;
buf.PLoanNumber := DFLoanNumber.Value;
buf.PYear := DFYear.Value;
buf.PDescription := DFDescription.Value;
buf.PVIN := DFVIN.Value;
buf.PExpenseReserve := DFExpenseReserve.Value;
buf.PCatCode := DFCatCode.Value;
buf.PBl_Prefix := DFBl_Prefix.Value;
buf.PBl_Policy := DFBl_Policy.Value;
buf.PBl_LossDate := DFBl_LossDate.Value;
buf.PBl_LossCode := DFBl_LossCode.Value;
result := buf;
end;
procedure TInfoCLAIMQuery.StoreDataBuffer(ABuffer:TInfoCLAIMRecord);
begin
DFClaimNumber.Value := ABuffer.PClaimNumber;
DFModCount.Value := ABuffer.PModCount;
DFPrefix.Value := ABuffer.PPrefix;
DFPolicy.Value := ABuffer.PPolicy;
DFLenderID.Value := ABuffer.PLenderID;
DFName.Value := ABuffer.PName;
DFRcvdDate.Value := ABuffer.PRcvdDate;
DFLossCode.Value := ABuffer.PLossCode;
DFLossDate.Value := ABuffer.PLossDate;
DFSettMeth.Value := ABuffer.PSettMeth;
DFDeniedDate.Value := ABuffer.PDeniedDate;
DFAppraisedDate.Value := ABuffer.PAppraisedDate;
DFApprRecvDate.Value := ABuffer.PApprRecvDate;
DFStmtYrMo.Value := ABuffer.PStmtYrMo;
DFModYrMo.Value := ABuffer.PModYrMo;
DFRepo.Value := ABuffer.PRepo;
DFRepoDate.Value := ABuffer.PRepoDate;
DFTrackCode.Value := ABuffer.PTrackCode;
DFReserve.Value := ABuffer.PReserve;
DFOpen.Value := ABuffer.POpen;
DFCollType.Value := ABuffer.PCollType;
DFUserID.Value := ABuffer.PUserID;
DFDiary.Value := ABuffer.PDiary;
DFEntryDate.Value := ABuffer.PEntryDate;
DFCompany.Value := ABuffer.PCompany;
DFLoanNumber.Value := ABuffer.PLoanNumber;
DFYear.Value := ABuffer.PYear;
DFDescription.Value := ABuffer.PDescription;
DFVIN.Value := ABuffer.PVIN;
DFExpenseReserve.Value := ABuffer.PExpenseReserve;
DFCatCode.Value := ABuffer.PCatCode;
DFBl_Prefix.Value := ABuffer.PBl_Prefix;
DFBl_Policy.Value := ABuffer.PBl_Policy;
DFBl_LossDate.Value := ABuffer.PBl_LossDate;
DFBl_LossCode.Value := ABuffer.PBl_LossCode;
end;
(********************************************)
(************ Register Component ************)
(********************************************)
procedure Register;
begin
RegisterComponents( 'Info Tables', [ TInfoCLAIMTable, TInfoCLAIMQuery, TInfoCLAIMBuffer ] );
end; { Register }
function TInfoCLAIMBuffer.FieldNameToIndex(s:string):integer;
const flist:array[1..35] of string = ('CLAIMNUMBER','MODCOUNT','PREFIX','POLICY','LENDERID','NAME'
,'RCVDDATE','LOSSCODE','LOSSDATE','SETTMETH','DENIEDDATE'
,'APPRAISEDDATE','APPRRECVDATE','STMTYRMO','MODYRMO','REPO'
,'REPODATE','TRACKCODE','RESERVE','OPEN','COLLTYPE'
,'USERID','DIARY','ENTRYDATE','COMPANY','LOANNUMBER'
,'YEAR','DESCRIPTION','VIN','EXPENSERESERVE','CATCODE'
,'BL_PREFIX','BL_POLICY','BL_LOSSDATE','BL_LOSSCODE' );
var x : integer;
begin
s := uppercase(s);
x := 1;
while (x <= 35) and (flist[x] <> s) do inc(x);
if x <= 35 then result := x else result := 0;
end;
function TInfoCLAIMBuffer.FieldType(index:integer):TFieldType;
begin
result := ftUnknown;
case index of
1 : result := ftString;
2 : result := ftInteger;
3 : result := ftString;
4 : result := ftString;
5 : result := ftString;
6 : result := ftString;
7 : result := ftString;
8 : result := ftString;
9 : result := ftString;
10 : result := ftString;
11 : result := ftString;
12 : result := ftString;
13 : result := ftString;
14 : result := ftString;
15 : result := ftString;
16 : result := ftBoolean;
17 : result := ftString;
18 : result := ftString;
19 : result := ftCurrency;
20 : result := ftString;
21 : result := ftString;
22 : result := ftString;
23 : result := ftString;
24 : result := ftString;
25 : result := ftString;
26 : result := ftString;
27 : result := ftString;
28 : result := ftString;
29 : result := ftString;
30 : result := ftCurrency;
31 : result := ftString;
32 : result := ftString;
33 : result := ftString;
34 : result := ftString;
35 : result := ftString;
end;
end;
function TInfoCLAIMBuffer.PtrIndex(index:integer):Pointer;
begin
result := nil;
case index of
1 : result := @Data.PClaimNumber;
2 : result := @Data.PModCount;
3 : result := @Data.PPrefix;
4 : result := @Data.PPolicy;
5 : result := @Data.PLenderID;
6 : result := @Data.PName;
7 : result := @Data.PRcvdDate;
8 : result := @Data.PLossCode;
9 : result := @Data.PLossDate;
10 : result := @Data.PSettMeth;
11 : result := @Data.PDeniedDate;
12 : result := @Data.PAppraisedDate;
13 : result := @Data.PApprRecvDate;
14 : result := @Data.PStmtYrMo;
15 : result := @Data.PModYrMo;
16 : result := @Data.PRepo;
17 : result := @Data.PRepoDate;
18 : result := @Data.PTrackCode;
19 : result := @Data.PReserve;
20 : result := @Data.POpen;
21 : result := @Data.PCollType;
22 : result := @Data.PUserID;
23 : result := @Data.PDiary;
24 : result := @Data.PEntryDate;
25 : result := @Data.PCompany;
26 : result := @Data.PLoanNumber;
27 : result := @Data.PYear;
28 : result := @Data.PDescription;
29 : result := @Data.PVIN;
30 : result := @Data.PExpenseReserve;
31 : result := @Data.PCatCode;
32 : result := @Data.PBl_Prefix;
33 : result := @Data.PBl_Policy;
34 : result := @Data.PBl_LossDate;
35 : result := @Data.PBl_LossCode;
end;
end;
end.
|
unit MainMenuNewRes;
// Библиотека : Проект Немезис;
// Название : MainMenuNewRes;
// Автор : М. Морозов;
// Назначение : Ресурсы основного меню системы;
// Версия : $Id: MainMenuNewRes.pas,v 1.3 2016/04/04 09:14:25 morozov Exp $
{-------------------------------------------------------------------------------
$Log: MainMenuNewRes.pas,v $
Revision 1.3 2016/04/04 09:14:25 morozov
Добавил иконы для Миши
Revision 1.2 2013/09/20 17:51:12 kostitsin
[$377169452] - MainMenu и InpharmMainMenu
Revision 1.1 2009/09/14 11:29:21 lulin
- выводим пути и для незавершённых модулей.
Revision 1.12 2007/04/25 10:14:30 oman
- fix: Вынес константу с фирменным цветом в общее место (cq25145)
Revision 1.11 2007/03/28 11:04:54 mmorozov
- "таблица перехода фокуса" перенесена в библиотеку визуальных компонентов проекта Немезис;
Revision 1.10 2007/01/15 06:28:46 mmorozov
- add log;
-------------------------------------------------------------------------------}
interface
uses
SysUtils, Classes, ImgList, Controls, Graphics, vtPngImgList;
const
/// Large icons //////////////////////////////////////////////////////////////
cimgLawfulNavigator = 0;
cimgInfo = 1;
cimgLastDocs = 2;
cimgSearch = 3;
cimgSituation = 4;
cimgPublish = 5;
cimgDiction = 6;
cimgPrime = 7;
cimgReview = 8;
cimgLawSupport = 9;
/// Small icons //////////////////////////////////////////////////////////////
cimgShow = 0;
cimgHide = 1;
//////////////////////////////////////////////////////////////////////////////
type
TdmMainMenuNew = class(TDataModule)
ilMainMenuNew: TvtPngImageList;
ilSmallIcons: TvtPngImageList;
ilButtons: TvtNonFixedPngImageList;
ilButtonsNew: TvtNonFixedPngImageList;
end;
var
dmMainMenuNew : TdmMainMenuNew;
implementation
{$R *.dfm}
end.
|
{ ***************************************************************************
Copyright (c) 2015-2019 Kike Pérez
Unit : Quick.Config.Registry
Description : Save config to Windows Registry
Author : Kike Pérez
Version : 1.5
Created : 21/10/2017
Modified : 12/04/2019
This file is part of QuickLib: https://github.com/exilon/QuickLib
***************************************************************************
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.
*************************************************************************** }
unit Quick.Config.Registry;
{$i QuickLib.inc}
interface
uses
Classes,
Windows,
SysUtils,
Registry,
Quick.Json.Serializer,
{$IFDEF DELPHIRX102_UP}
System.Json,
System.JSON.Types,
{$ELSE}
{$IFDEF FPC}
fpjson,
//jsonparser,
//fpjsonrtti,
Quick.Json.fpc.Compatibility,
{$ELSE}
Rest.Json.Types,
System.JSON,
Rest.Json,
{$ENDIF}
{$ENDIF}
Quick.Commons,
Quick.Config.Base;
type
{$IFNDEF FPC}
TNotSerializableProperty = Quick.Json.Serializer.TNotSerializableProperty;
TCommentProperty = Quick.Json.Serializer.TCommentProperty;
TCustomNameProperty = Quick.Json.Serializer.TCustomNameProperty;
{$ENDIF}
TAppConfigRegistryProvider = class(TAppConfigProvider)
private
fRootKey : HKEY;
fMainKey : string;
fRegConfig : TRegistry;
function JsonToRegistry(const StrJson : string) : Boolean;
function RegistryToJson(out StrJson : string) : Boolean;
class function IsSimpleJsonValue(v: TJSONValue): Boolean;
function IsRegKeyObject(const cCurrentKey : string = '') : Boolean;
function IsRegKeyArray(const cCurrentKey : string = '') : Boolean;
function ProcessPairRead(const cCurrentKey, cRegKey : string; aIndex : Integer) : TJSONValue;
function ProcessElementRead(const cCurrentKey, cRegKey : string; aIndex : Integer) : TJSONValue;
procedure ProcessPairWrite(const cCurrentKey: string; obj: TJSONObject; aIndex: integer);
procedure ProcessElementWrite(const cCurrentKey: string; arr: TJSONArray; aIndex, aMax : integer);
function AddRegKey(const cCurrentKey, NewKey : string) : Boolean;
function ReadRegValue(const cCurrentKey, cName : string) : TJSONValue;
procedure AddRegValue(const cCurrentKey, cName : string; cValue : TJSONValue);
protected
procedure Load(cConfig : TAppConfig); override;
procedure Save(cConfig : TAppConfig); override;
public
constructor Create(aHRoot : HKEY = HKEY_CURRENT_USER; const aMainKey : string = ''); virtual;
destructor Destroy; override;
property HRoot : HKEY read fRootKey write fRootKey;
property MainKey : string read fMainKey write fMainKey;
end;
EAppConfig = Exception;
TAppConfigRegistry = class(TAppConfig)
private
function GetProvider : TAppConfigRegistryProvider;
public
constructor Create(aHRoot : HKEY = HKEY_CURRENT_USER; const aMainKey : string = '');
destructor Destroy; override;
property Provider : TAppConfigRegistryProvider read GetProvider;
end;
{Usage: create a descend class from TAppConfigRegistry and add published properties to be loaded/saved
TMyConfig = class(TAppConfigRegistry)
private
fName : string;
fSurname : string;
fStatus : Integer;
published
property Name : string read fName write fName;
property SurName : string read fSurname write fSurname;
property Status : Integer read fStatus write fStatus;
end;
MyConfig := TMyConfig.Create;
MyConfig.Provider.MainKey := 'MyAppName';
MyConfig.Name := 'John';
MyConfig.Save;
}
implementation
{ TAppConfigRegistryProvider }
constructor TAppConfigRegistryProvider.Create(aHRoot : HKEY = HKEY_CURRENT_USER; const aMainKey : string = '');
begin
inherited Create;
if aHRoot <> HKEY_CURRENT_USER then fRootKey := aHRoot
else fRootKey := HKEY_CURRENT_USER;
if aMainKey <> '' then fMainKey := aMainKey
else fMainKey := ExtractFileNameWithoutExt(ParamStr(0));
fRegConfig := TRegistry.Create(KEY_READ or KEY_WRITE);
end;
destructor TAppConfigRegistryProvider.Destroy;
begin
if Assigned(fRegConfig) then fRegConfig.Free;
inherited;
end;
procedure TAppConfigRegistryProvider.Load(cConfig : TAppConfig);
var
Serializer: TJsonSerializer;
json : string;
begin
fRegConfig.Access := KEY_READ;
fRegConfig.RootKey := fRootKey;
if not fRegConfig.KeyExists('\Software\' + fMainKey) then
begin
if not CreateIfNotExists then raise EAppConfig.Create('Not exists MainKey in registry!')
else TAppConfigRegistry(cConfig).DefaultValues;
Save(cConfig);
end;
RegistryToJson(json);
serializer := TJsonSerializer.Create(slPublishedProperty);
try
serializer.JsonToObject(cConfig,json);
finally
serializer.Free;
end;
end;
procedure TAppConfigRegistryProvider.Save(cConfig : TAppConfig);
begin
JsonToRegistry(cConfig.ToJSON);
end;
function TAppConfigRegistryProvider.JsonToRegistry(const StrJson : string) : Boolean;
var
jValue : TJSONValue;
aCount : Integer;
i : Integer;
aCurrentKey : string;
begin
Result := False;
if fMainKey = '' then raise EAppConfig.Create('MainKey not defined!');
fRegConfig.Access := KEY_READ or KEY_WRITE;
fRegConfig.RootKey := fRootKey;
aCurrentKey := '\Software\' + fMainKey;
if fRegConfig.KeyExists(aCurrentKey) then
begin
try
if fRegConfig.KeyExists(aCurrentKey + '_bak') then fRegConfig.DeleteKey(aCurrentKey + '_bak');
fRegConfig.MoveKey(aCurrentKey,aCurrentKey + '_bak',True);
except
raise EAppConfig.Create('Can''t write Config Registry');
end;
end;
try
if not AddRegKey('\Software',fMainKey) then
begin
raise EAppConfig.Create('Can''t create key');
end;
{$IFNDEF FPC}
jValue := TJSONObject.ParseJSONValue(TEncoding.ASCII.GetBytes(StrJson),0) as TJSONValue;
{$ELSE}
jValue := TJSONObject.ParseJSONValue(StrJson) as TJSONValue;
{$ENDIF}
try
if IsSimpleJsonValue(jValue) then
begin
{$IFNDEF FPC}
AddRegValue(aCurrentKey,TJSONPair(jValue).JsonString.ToString.DeQuotedString('"'),TJSONPair(jValue).JsonValue);
{$ELSE}
AddRegValue(aCurrentKey,TJSONPair(jValue).JsonString.DeQuotedString('"'),TJSONPair(jValue).JsonValue);
{$ENDIF}
end
{$IFNDEF FPC}
else if jValue is TJSONObject then
{$ELSE}
else if jvalue.JSONType = jtObject then
{$ENDIF}
begin
aCount := TJSONObject(jValue).Count;
for i := 0 to aCount - 1 do
ProcessPairWrite(aCurrentKey,TJSONObject(jValue),i);
end
{$IFNDEF FPC}
else if jValue is TJSONArray then
{$ELSE}
else if jValue.JSONType = jtArray then
{$ENDIF}
begin
aCount := TJSONArray(jValue).Count;
for i := 0 to aCount - 1 do
ProcessElementWrite(aCurrentKey,TJSONArray(jValue),i,aCount);
end
else raise EAppConfig.Create('Error Saving config to Registry');
Result := True;
finally
jValue.Free;
end;
if fRegConfig.KeyExists(aCurrentKey + '_bak') then fRegConfig.DeleteKey(aCurrentKey + '_bak');
except
on E : Exception do
begin
fRegConfig.DeleteKey(aCurrentKey);
fRegConfig.MoveKey(aCurrentKey+'_bak',aCurrentKey,True);
raise EAppConfig.Create(e.message);
end;
end;
end;
function TAppConfigRegistryProvider.RegistryToJson(out StrJson : string) : Boolean;
var
jValue : TJSONValue;
jPair : TJSONPair;
jArray : TJSONArray;
a, b : string;
aCount : Integer;
i : Integer;
aName : string;
aValue : TJSONValue;
aCurrentKey : string;
newObj : TJSONObject;
RegKeyList : TStringList;
RegValueList : TStringList;
RegKey : string;
RegValue : string;
RegKeyInfo : TRegKeyInfo;
begin
Result := False;
//check if exists root key
fRegConfig.Access := KEY_READ;
fRegConfig.RootKey := fRootKey;
if fRegConfig.KeyExists('\Software\' + fMainKey) then
begin
fRegConfig.OpenKeyReadOnly('\Software\' + fMainKey);
aCurrentKey := '\Software\' + fMainKey;
end
else raise EAppConfig.Create('Can''t read key');
newObj := TJSONObject.Create;
try
//read root values
RegValueList := TStringList.Create;
try
fRegConfig.GetValueNames(RegValueList);
for RegValue in RegValueList do
begin
newObj.AddPair(RegValue,ReadRegValue(aCurrentKey,RegValue));
end;
finally
RegValueList.Free;
end;
//read root keys
RegKeyList := TStringList.Create;
try
fRegConfig.GetKeyNames(RegKeyList);
for RegKey in RegKeyList do
begin
fRegConfig.OpenKeyReadOnly(aCurrentKey + '\' + RegKey);
if IsRegKeyObject then
begin
jValue := ProcessPairRead(aCurrentKey + '\' + RegKey,Regkey,i);
newObj.AddPair(RegKey,jValue);
end
else if IsRegKeyArray then
begin
jValue := ProcessElementRead(aCurrentKey + '\' + RegKey,Regkey,i);
newObj.AddPair(RegKey,jValue);
end
else raise EAppConfig.Create('Unknow value reading Config Registry');
end;
finally
RegKeyList.Free;
end;
StrJson := newObj.ToJSON;
finally
newObj.Free;
end;
end;
function TAppConfigRegistryProvider.IsRegKeyObject(const cCurrentKey : string = '') : Boolean;
begin
Result := not IsRegKeyArray(cCurrentKey);
end;
function TAppConfigRegistryProvider.IsRegKeyArray(const cCurrentKey : string = '') : Boolean;
var
RegValue : string;
RegValueList : TStrings;
RegKey : string;
RegKeyList : TStrings;
n : Integer;
begin
Result := False;
if cCurrentKey <> '' then fRegConfig.OpenKeyReadOnly(cCurrentKey);
//check if exists RegKey numeric (indicates is a Array)
RegKeyList := TStringList.Create;
try
{$IFNDEF FPC}
fRegConfig.GetKeyNames(RegKeyList);
{$ELSE}
try
fRegConfig.GetKeyNames(RegKeyList);
except
end;
{$ENDIF}
for RegKey in RegKeyList do
if TryStrToInt(RegKey,n) then
begin
Result := True;
Break;
end;
finally
RegKeyList.Free;
end;
//check if exists RegValue numeric (indicates is a Array)
RegValueList := TStringList.Create;
try
{$IFNDEF FPC}
fRegConfig.GetValueNames(RegValueList);
{$ELSE}
try
fRegConfig.GetValueNames(RegValueList);
except
end;
{$ENDIF}
for RegValue in RegValueList do
if TryStrToInt(RegValue,n) then
begin
Result := True;
Break;
end;
finally
RegValueList.Free;
end;
end;
class function TAppConfigRegistryProvider.IsSimpleJsonValue(v: TJSONValue): Boolean;
begin
Result := (v is {$IFDEF FPC}fpjson.TJsonIntegerNumber{$ELSE}TJSONNumber{$ENDIF})
or (v is {$IFDEF FPC}fpjson.{$ENDIF}TJSONString)
{$IFNDEF FPC}
or (v is TJSONTrue)
or (v is TJSONFalse)
{$ELSE}
or (v is {$IFDEF FPC}fpjson.TJSONBoolean{$ELSE}TJsonBool{$ENDIF})
{$ENDIF}
or (v is {$IFDEF FPC}fpjson.{$ENDIF}TJSONNull);
end;
function TAppConfigRegistryProvider.ReadRegValue(const cCurrentKey, cName : string) : TJSONValue;
var
aValue : string;
RegInfo : TRegDataInfo;
begin
if fRegConfig.OpenKeyReadOnly(cCurrentKey) then
begin
if fRegConfig.GetDataInfo(cName,RegInfo) then
case RegInfo.RegData of
rdInteger : Result := TJSONNumber.Create(fRegConfig.ReadInteger(cName));
rdString :
begin
aValue := fRegConfig.ReadString(cName);
if aValue.ToLower = 'true' then Result := TJSONBool.Create(True)
else if aValue.ToLower = 'false' then Result := TJSONBool.Create(False)
else Result := TJSONString.Create(aValue);
end;
else Result := TJSONNull.Create;
end;
end;
end;
function TAppConfigRegistryProvider.AddRegKey(const cCurrentKey, NewKey : string) : Boolean;
begin
Result := fRegConfig.CreateKey(Format('%s\%s',[cCurrentKey,NewKey]));
end;
procedure TAppConfigRegistryProvider.AddRegValue(const cCurrentKey, cName : string; cValue : TJSONValue);
var
aName : string;
aValue : string;
begin
aName := cName.DeQuotedString('"');
{$IFNDEF FPC}
aValue := cValue.ToString.DeQuotedString('"');
{$ELSE}
aValue := cValue.AsString;// .DeQuotedString('"');
{$ENDIF}
fRegConfig.OpenKey(cCurrentKey,True);
if cValue is {$IFDEF FPC}fpjson.TJSONIntegerNumber{$ELSE}TJSONNumber{$ENDIF} then fRegConfig.WriteInteger(aName,StrToInt64(aValue))
else if cValue is {$IFDEF FPC}fpjson.{$ENDIF}TJSONString then fRegConfig.WriteString(aName,aValue)
else if cValue is {$IFDEF FPC}fpjson.TJSONBoolean{$ELSE}TJSONBool{$ENDIF} then fRegConfig.WriteString(aName,aValue);
//else if cValue is TJSONNull then fRegConfig.WriteString(aName,'');
end;
function TAppConfigRegistryProvider.ProcessPairRead(const cCurrentKey, cRegKey : string; aIndex : Integer) : TJSONValue;
var
i : Integer;
jValue : TJSONValue;
RegValue : string;
RegValueList : TStrings;
RegKey : string;
RegKeyList : TStrings;
newObj : TJSONObject;
begin
newObj := TJSONObject.Create;
//read root values
RegValueList := TStringList.Create;
try
{$IFNDEF FPC}
fRegConfig.GetValueNames(RegValueList);
{$ELSE}
try
fRegConfig.GetValueNames(RegValueList);
except
end;
{$ENDIF}
for RegValue in RegValueList do
begin
newObj.AddPair(RegValue,ReadRegValue(cCurrentKey,RegValue));
end;
finally
RegValueList.Free;
end;
//read root keys
RegKeyList := TStringList.Create;
try
{$IFNDEF FPC}
fRegConfig.GetKeyNames(RegKeyList);
{$ELSE}
try
fRegConfig.GetKeyNames(RegKeyList);
except
end;
{$ENDIF}
for RegKey in RegKeyList do
begin
fRegConfig.OpenKeyReadOnly(cCurrentKey + '\' + RegKey);
if IsRegKeyObject then
begin
jValue := ProcessPairRead(cCurrentKey + '\' + RegKey,Regkey,i);
newObj.AddPair(RegKey,jValue);
end
else if IsRegKeyArray then
begin
jValue := ProcessElementRead(cCurrentKey + '\' + RegKey,Regkey,i);
newObj.AddPair(RegKey,jValue);
end
else raise EAppConfig.Create('Unknow value reading Config Registry');
end;
finally
RegKeyList.Free;
end;
Result := TJsonValue(newObj);
end;
function TAppConfigRegistryProvider.ProcessElementRead(const cCurrentKey, cRegKey : string; aIndex : Integer) : TJSONValue;
var
i : Integer;
jValue : TJSONValue;
RegValue : string;
RegValueList : TStrings;
RegKey : string;
RegKeyList : TStrings;
newObj : TJSONArray;
begin
newObj := TJSONArray.Create;
//read root values
RegValueList := TStringList.Create;
try
{$IFNDEF FPC}
fRegConfig.GetValueNames(RegValueList);
{$ELSE}
try
fRegConfig.GetValueNames(RegValueList);
except
end;
{$ENDIF}
for RegValue in RegValueList do
begin
newObj.AddElement(ReadRegValue(cCurrentKey,RegValue));
end;
finally
RegValueList.Free;
end;
//read root keys
RegKeyList := TStringList.Create;
try
{$IFNDEF FPC}
fRegConfig.GetKeyNames(RegKeyList);
{$ELSE}
try
fRegConfig.GetKeyNames(RegKeyList);
except
end;
{$ENDIF}
for RegKey in RegKeyList do
begin
fRegConfig.OpenKeyReadOnly(cCurrentKey + '\' + RegKey);
if IsRegKeyObject then
begin
jValue := ProcessPairRead(cCurrentKey + '\' + RegKey,Regkey,i);
newObj.AddElement(jValue);
end
else if IsRegKeyArray then
begin
jValue := ProcessElementRead(cCurrentKey + '\' + RegKey,Regkey,i);
newObj.AddElement(jValue);
end
else raise EAppConfig.Create('Unknow value reading Config Registry');
end;
finally
RegKeyList.Free;
end;
Result := TJsonValue(newObj);
end;
procedure TAppConfigRegistryProvider.ProcessPairWrite(const cCurrentKey: string; obj: TJSONObject; aIndex: integer);
var
jPair: TJSONPair;
i : Integer;
aCount: integer;
begin
jPair := obj.Pairs[aIndex];
if IsSimpleJsonValue(jPair.JsonValue) then
begin
AddRegValue(cCurrentKey,jPair.JsonString{$IFNDEF FPC}.ToString{$ENDIF},jPair.JsonValue);
Exit;
end;
if jPair.JsonValue is {$IFDEF FPC}fpjson.{$ENDIF}TJSONObject then
begin
aCount := TJSONObject(jPair.JsonValue).Count;
for i := 0 to aCount - 1 do
ProcessPairWrite(cCurrentKey + '\' + jPair.JsonString{$IFNDEF FPC}.ToString{$ENDIF}.DeQuotedString('"'), TJSONObject(jPair.JsonValue),i);
end
else if jPair.JsonValue is {$IFDEF FPC}fpjson.{$ENDIF}TJSONArray then
begin
aCount := TJSONArray(jPair.JsonValue).Count;
for i := 0 to aCount - 1 do
ProcessElementWrite(cCurrentKey + '\' + jPair.JsonString{$IFNDEF FPC}.ToString{$ENDIF}.DeQuotedString('"'), TJSONArray(jPair.JsonValue),i,aCount);
end
else raise EAppConfig.Create('Error Saving config to Registry');
end;
procedure TAppConfigRegistryProvider.ProcessElementWrite(const cCurrentKey: string; arr: TJSONArray; aIndex, aMax: integer);
var
jValue: TJSONValue;
i : Integer;
aCount: integer;
dig : Integer;
begin
jValue := arr.Items[aIndex];
dig := CountDigits(aMax);
if IsSimpleJsonValue(jValue) then
begin
AddRegValue(cCurrentKey,Zeroes(aIndex,dig),jValue);
Exit;
end;
if jValue is {$IFDEF FPC}fpjson.{$ENDIF}TJSONObject then
begin
aCount := TJSONObject(jValue).Count;
for i := 0 to aCount - 1 do
ProcessPairWrite(cCurrentKey + '\' + Zeroes(aIndex,dig),TJSONObject(jValue),i);
end
else if jValue is {$IFDEF FPC}fpjson.{$ENDIF}TJSONArray then
begin
aCount := TJSONArray(jValue).Count;
for i := 0 to aCount - 1 do
ProcessElementWrite(cCurrentKey + '\' + Zeroes(i,dig),TJSONArray(jValue),i,aCount);
end
else raise EAppConfig.Create('Error Saving config to Registry');
end;
{ TAppConfigRegistry }
constructor TAppConfigRegistry.Create(aHRoot : HKEY = HKEY_CURRENT_USER; const aMainKey : string = '');
begin
inherited Create(TAppConfigRegistryProvider.Create(aHRoot,aMainKey));
end;
destructor TAppConfigRegistry.Destroy;
begin
inherited;
end;
function TAppConfigRegistry.GetProvider: TAppConfigRegistryProvider;
begin
if not Assigned(fProvider) then raise EAppConfig.Create('No provider assigned!');
Result := TAppConfigRegistryProvider(fProvider);
end;
end.
|
unit dmPrincipal;
interface
uses
System.SysUtils, System.Classes, System.IniFiles, Vcl.Forms, Vcl.Dialogs,
FireDAC.Stan.Intf, FireDAC.Stan.Option, FireDAC.Stan.Error, FireDAC.UI.Intf,
FireDAC.Phys.Intf, FireDAC.Stan.Def, FireDAC.Stan.Pool, FireDAC.Stan.Async,
FireDAC.Phys, FireDAC.Phys.FB, FireDAC.Phys.FBDef, Data.DB,
FireDAC.Comp.Client, FireDAC.Stan.Param, FireDAC.DatS, FireDAC.DApt.Intf,
FireDAC.DApt, FireDAC.Comp.DataSet, FireDAC.VCLUI.Wait, FireDAC.Comp.UI,
FireDAC.Phys.IBBase, Data.SqlExpr;
type
TfrmDmPrincipal = class(TDataModule)
FDConnexao: TFDConnection;
FDPhysFBDriverLink1: TFDPhysFBDriverLink;
FDGUIxWaitCursor1: TFDGUIxWaitCursor;
procedure DataModuleCreate(Sender: TObject);
procedure DataModuleDestroy(Sender: TObject);
private
{ Private declarations }
configuracao: TIniFile;
public
{ Public declarations }
end;
var
frmDmPrincipal: TfrmDmPrincipal;
implementation
const
BANCO_RADIUS = 'radius.gdb';
{ %CLASSGROUP 'Vcl.Controls.TControl' }
{$R *.dfm}
procedure TfrmDmPrincipal.DataModuleCreate(Sender: TObject);
begin
configuracao := TIniFile.Create(ExtractFilePath(Application.ExeName) +
'Radius.ini');
FDConnexao.Params.Clear();
FDConnexao.Params.Add('User_Name=' + 'sysdba');
FDConnexao.Params.Add('Password=' + 'masterkey');
FDConnexao.Params.Add('DriverID=' + 'FB');
FDConnexao.Params.Add('Server=' + configuracao.ReadString('CONEXAO',
'IntProtoc', ''));
FDConnexao.Params.Add('Database=' + configuracao.ReadString('CONEXAO',
'Diretorio', '') + BANCO_RADIUS);
try
FDConnexao.Connected := True;
except
ShowMessage('Erro ao se conectar com base de dados!' + #13 +
'Por favor, verifique o arquivo de configuração: Radius.ini ');
Application.Terminate;
end;
end;
procedure TfrmDmPrincipal.DataModuleDestroy(Sender: TObject);
begin
FreeAndNil(configuracao);
end;
end.
|
unit SimpleSVD;
interface
uses
System.Classes,
System.SysUtils,
System.Math;
type
TSVDFloat = Double;
TSVDFloatArray = TArray<TSVDFloat>;
TMatrix = class
private
FRows: Integer;
FCols: Integer;
FName: string;
FType: Integer;
FMat: TSVDFloatArray;
function GetMat(Index: Integer): TSVDFloat;
procedure SetMat(Index: Integer; const Value: TSVDFloat);
function GetMatrix(row, col: Integer): TSVDFloat;
procedure SetMatrix(row, col: Integer; const Value: TSVDFloat);
public const
AS_MATRIX = 1;
AS_VECTOR = 2;
public
constructor Create(M, N: Integer; aName: string; aType: Integer);
procedure Output(Lines: TStrings);
procedure SetAll(const aMat: TSVDFloatArray);
property Mat[Index: Integer]: TSVDFloat read GetMat write SetMat;
property Rows: Integer read FRows;
property Cols: Integer read FCols;
property Name: string read FName;
property MatrixType: Integer read FType;
property Matrix[row, col: Integer]: TSVDFloat read GetMatrix write SetMatrix; default;
end;
TSVD = class
public
constructor Create;
function Multiply (m1, m2, y: TMatrix): Integer;
function PinvCompute(A: TMatrix; rows, cols: Integer): TMatrix;
function PseudoInverseSVD(const V,S,U: TSVDFloatArray; rows,cols: Integer): TSVDFloatArray;
procedure GivensL(var S_: TSVDFloatArray; const dim: TArray<Integer>; m: Integer; a, b: TSVDFloat);
procedure GivensR(var S_: TSVDFloatArray; const dim: TArray<Integer>; m: Integer; a, b: TSVDFloat);
procedure SVDDecomp(const dim: TArray<Integer>; var U_, S_, V_: TSVDFloatArray; eps: Double);
procedure SVDCompute(M, N: Integer; const A: TSVDFloatArray; LDA: Integer;
var S, U: TSVDFloatArray; LDU: Integer; var VT: TSVDFloatArray;
LDVT: Integer);
end;
implementation
{ TMatrix }
constructor TMatrix.Create(M, N: Integer; aName: string; aType: Integer);
begin
FRows := M;
FCols := N;
FName := aName;
FType := aType;
SetLength(FMat, M * N);
end;
function TMatrix.GetMat(Index: Integer): TSVDFloat;
begin
Assert(Index < FRows * FCols);
Result := FMat[Index];
end;
function TMatrix.GetMatrix(row, col: Integer): TSVDFloat;
begin
Assert((row < FRows) and (col < FCols));
Result := FMat[row * FCols + col];
end;
procedure TMatrix.Output(Lines: TStrings);
var
s: string;
i, j: Integer;
begin
if(FType=AS_MATRIX) then
begin
Lines.Add('Matrix ' + FName + ':');
for i:=0 to FRows-1 do
begin
s := '';
for j:=0 to FCols-1 do
begin
if(FMat[i*cols+j]<10E-13) and (FMat[i*cols+j]>-10E-13) then
mat[i*cols+j] := 0;
s := s + Format('%12.4g', [FMat[i*FCols+j]]);
end;
Lines.Add(s);
end;
Lines.Add('');
end
else if(FType=AS_VECTOR) then
begin
Lines.Add('Vector ' + FName + ':');
s := '';
for i:=0 to FRows-1 do
begin
if(FMat[i]<10E-13) and (FMat[i]>-10E-13) then
mat[i*cols] := 0;
s := s + Format('%13.4f', [FMat[i]]);
end;
Lines.Add(s);
Lines.Add('');
end;
end;
procedure TMatrix.SetAll(const aMat: TSVDFloatArray);
begin
FMat := aMat;
end;
procedure TMatrix.SetMat(Index: Integer; const Value: TSVDFloat);
begin
Assert(Index < FRows * FCols);
FMat[Index] := Value;
end;
procedure TMatrix.SetMatrix(row, col: Integer; const Value: TSVDFloat);
begin
Assert((row < FRows) and (col < FCols));
FMat[row * FCols + col] := Value;
end;
{ TSVD }
constructor TSVD.Create;
begin
end;
//#define U(i,j) U_[(i)*dim[0]+(j)]
//#define S(i,j) S_[(i)*dim[1]+(j)]
//#define V(i,j) V_[(i)*dim[1]+(j)]
procedure TSVD.GivensL(var S_: TSVDFloatArray; const dim: TArray<Integer>;
m: Integer; a, b: TSVDFloat);
var
r, c, s: TSVDFloat;
i, idx0, idx1: Integer;
S0, S1: TSVDFloat;
begin
r:=sqrt(a*a+b*b);
c:=a/r;
s:=-b/r;
for i:=0 to dim[1]-1 do
begin
idx0 := (m+0)*dim[0]+(i); //S(m+0,i)
idx1 := (m+1)*dim[0]+(i); //S(m+1,i)
S0:=S_[idx0];
S1:=S_[idx1];
S_[idx0] := S_[idx0] + S0*(c-1) + S1*(-s);
S_[idx1] := S_[idx1] + S0*(s) + S1*(c-1);
end;
end;
procedure TSVD.GivensR(var S_: TSVDFloatArray; const dim: TArray<Integer>;
m: Integer; a, b: TSVDFloat);
var
r, c, s: TSVDFloat;
i, idx0, idx1: Integer;
S0, S1: TSVDFloat;
begin
r:=sqrt(a*a+b*b);
c:=a/r;
s:=-b/r;
for i:=0 to dim[0]-1 do
begin
idx0 := (i)*dim[0]+(m+0); //S(i,m+0)
idx1 := (i)*dim[0]+(m+1); //S(i,m+1);
S0:=S_[idx0];
S1:=S_[idx1];
S_[idx0] := S_[idx0] + S0*(c-1) + S1*(-s);
S_[idx1] := S_[idx1] + S0*(s) + S1*(c-1);
end;
end;
function TSVD.Multiply(m1, m2, y: TMatrix): Integer;
var
sum: Double;
I, J, K: Integer;
begin
if (m1.Cols <> m2.Rows) then
Exit(0);
for I := 0 to m1.Rows-1 do
begin
for J := 0 to m2.Cols-1 do
begin
sum := 0;
for K := 0 to m1.Cols-1 do
begin
sum := sum + m1[i,k] * m2[k,j];
end;
y[i,j] := sum;
end;
end;
Result := 1;
end;
function TSVD.PinvCompute(A: TMatrix; rows, cols: Integer): TMatrix;
var
U, VT, S: TMatrix;
Mat: TSVDFloatArray;
I, J: Integer;
m, n: Integer;
tU, tS, tVT, pinv: TSVDFloatArray;
begin
Result := TMatrix.Create(cols,rows,'A_pinv',TMatrix.AS_MATRIX);
U:=TMatrix.Create(rows,cols,'U',TMatrix.AS_MATRIX);
VT:=TMatrix.Create(cols,cols,'VT',TMatrix.AS_MATRIX);
S:=TMatrix.Create(cols,cols,'S',TMatrix.AS_MATRIX);
SetLength(Mat, rows*cols);
try
for I:=0 to rows*cols-1 do
Mat[i]:=A.Mat[i];
m := cols;
n := rows;
SetLength(tU, m*m);
SetLength(tS, m);
SetLength(tVT, m*n);
SvdCompute(m, n, Mat, m, tS, tU, m, tVT, m);
for I:=0 to rows-1 do
for j:=0 to cols-1 do
U.Mat[i*cols+j] := tVT[i*cols+j];
for i:=0 to cols-1 do
for j:=0 to cols-1 do
VT.Mat[i*cols+j] := tU[i*cols+j];
for i:=0 to cols-1 do
for j:=0 to cols-1 do
begin
if(i=j) then
S.Mat[i*cols+j]:=tS[i]
else
S.Mat[i*cols+j]:=0;
end;
pinv := PseudoInverseSVD(tVT,tS,tU,m,n);
Result.SetAll(pinv);
finally
S.Free;
VT.Free;
U.Free;
end;
end;
function TSVD.PseudoInverseSVD(const V, S, U: TSVDFloatArray; rows,
cols: Integer): TSVDFloatArray;
var
temp: TSVDFloatArray;
I, J, K: Integer;
sum: TSVDFloat;
begin
SetLength(temp, rows*rows);
for I:=0 to rows-1 do
for J := 0 to rows-1 do
temp[i*rows+j] := U[j*rows+i]/S[j];
SetLength(Result, rows*cols);
for i:=0 to rows-1 do
for j:=0 to cols-1 do
begin
sum:=0;
for k:=0 to rows-1 do
sum:=sum+temp[i*rows+k]*V[j*rows+k];
Result[i*cols+j]:=sum;
end;
end;
procedure TSVD.SVDCompute(M, N: Integer; const A: TSVDFloatArray; LDA: Integer;
var S, U: TSVDFloatArray; LDU: Integer; var VT: TSVDFloatArray;
LDVT: Integer);
var
dim: TArray<Integer>;
U_, V_, S_: TSVDFloatArray;
i, j: Integer;
tmp: TSVDFloat;
begin
dim := TArray<Integer>.Create(Max(N, M), Min(N, M));
SetLength(U_, dim[0]*dim[0]);
SetLength(V_, dim[1]*dim[1]);
SetLength(S_, dim[0]*dim[1]);
FillChar(U_[0], dim[0]*dim[0]*SizeOf(TSVDFloat), 0);
FillChar(V_[0], dim[1]*dim[1]*SizeOf(TSVDFloat), 0);
if(dim[1]=M) then
begin
for I := 0 to dim[0]-1 do
for J := 0 to dim[1]-1 do
begin
S_[i*dim[1]+j]:=A[i*lda+j];
end;
end
else
begin
for I := 0 to dim[0]-1 do
for J := 0 to dim[1]-1 do
begin
S_[i*dim[1]+j]:=A[j*lda+i];
end;
end;
for i:=0 to dim[0]-1 do
begin
U_[i*dim[0]+i]:=1;
end;
for i:=0 to dim[1]-1 do
begin
V_[i*dim[1]+i]:=1;
end;
SvdDecomp(dim, U_, S_, V_, -1.0);
for i:=0 to dim[1]-1 do
begin
S[i]:=S_[i*dim[1]+i];
end;
if(dim[1]=M) then
begin
for I := 0 to dim[1]-1 do
for J := 0 to M-1 do
begin
if S[i] < 0.0 then
tmp := -1.0
else
tmp := 1.0;
U[j+ldu*i]:=V_[j+i*dim[1]]*tmp;
end;
end
else
begin
for I := 0 to dim[1]-1 do
for J := 0 to M-1 do
begin
if S[i] < 0.0 then
tmp := -1.0
else
tmp := 1.0;
U[j+ldu*i]:=U_[i+j*dim[0]]*tmp;
end;
end;
if(dim[0]=N) then
begin
for i:=0 to N-1 do
for j:=0 to dim[1]-1 do
begin
VT[j+ldvt*i]:=U_[j+i*dim[0]];
end;
end
else
begin
for i:=0 to N-1 do
for j:=0 to dim[1]-1 do
begin
VT[j+ldvt*i]:=V_[i+j*dim[1]];
end;
end;
for i:=0 to dim[1]-1 do
begin
if S[i] < 0.0 then
tmp := -1.0
else
tmp := 1.0;
S[i]:=S[i]*tmp;
end;
end;
procedure TSVD.SVDDecomp(const dim: TArray<Integer>; var U_, S_,
V_: TSVDFloatArray; eps: Double);
var
N: Integer;
x1: TSVDFloat;
x_inv_norm, dot_prod: Double;
house_vec: TArray<Double>;
i, j, K, idx, k0, idx2, i0, i1: Integer;
tmp: TSVDFloat;
alpha, beta, S_max: Double;
c: array [0 .. 1, 0 .. 1] of Double;
b, c2, d, lambda1, lambda2, d1, d2, mu: Double;
dimU, dimV: TArray<Integer>;
begin
Assert(dim[0] >= dim[1]);
N := Min(dim[0], dim[1]);
SetLength(house_vec, Max(dim[0], dim[1]));
// S(i,j) S_[(i)*dim[1]+(j)]
for i := 0 to N - 1 do
begin
x1 := S_[(i) * dim[1] + (i)]; // S(i,i);
if (x1 < 0) then
x1 := -x1;
x_inv_norm := 0;
for j := i to dim[0] - 1 do
begin
x_inv_norm := x_inv_norm + Sqr(S_[(j) * dim[1] + (i)]); // s(j,i)*s(j,i)
end;
if (x_inv_norm > 0) then
x_inv_norm := 1 / sqrt(x_inv_norm);
alpha := sqrt(1 + x1 * x_inv_norm);
beta := x_inv_norm / alpha;
house_vec[i] := -alpha;
for j := i + 1 to dim[0] - 1 do
begin
house_vec[j] := -beta * S_[(j) * dim[1] + (i)];
end;
if (S_[(i) * dim[1] + (i)] < 0) then
for j := i + 1 to dim[0] - 1 do
begin
house_vec[j] := -house_vec[j];
end;
for K := i to dim[1] - 1 do
begin
dot_prod := 0;
for j := i to dim[0] - 1 do
begin
dot_prod := dot_prod + S_[(j) * dim[1] + (K)] * house_vec[j];
end;
for j := i to dim[0] - 1 do
begin
idx := (j) * dim[1] + (K);
S_[idx] := S_[idx] - dot_prod * house_vec[j];
end;
end;
// #define U(i,j) U_[(i)*dim[0]+(j)]
for K := 0 to dim[0] - 1 do
begin
dot_prod := 0;
for j := i to dim[0] - 1 do
begin
dot_prod := dot_prod + U_[(K) * dim[0] + (j)] * house_vec[j];
end;
for j := i to dim[0] - 1 do
begin
idx := (K) * dim[0] + (j);
U_[idx] := U_[idx] - dot_prod * house_vec[j];
end;
end;
if (i >= N - 1) then
continue;
begin
x1 := S_[(i) * dim[1] + (i + 1)]; // S(i,i+1);
if (x1 < 0) then
x1 := -x1;
x_inv_norm := 0;
for j := i + 1 to dim[1] - 1 do
begin
x_inv_norm := x_inv_norm + Sqr(S_[(i) * dim[1] + (j)]); // S(i,j);
end;
if (x_inv_norm > 0) then
x_inv_norm := 1 / sqrt(x_inv_norm);
alpha := sqrt(1 + x1 * x_inv_norm);
beta := x_inv_norm / alpha;
house_vec[i + 1] := -alpha;
for j := i + 2 to dim[1] - 1 do
begin
house_vec[j] := -beta * S_[(i) * dim[1] + (j)]; // S(i,j);
end;
if (S_[(i) * dim[1] + (i + 1)] < 0) then
for j := i + 2 to dim[1] - 1 do
begin
house_vec[j] := -house_vec[j];
end;
end;
for K := i to dim[0] - 1 do
begin
dot_prod := 0;
for j := i + 1 to dim[1] - 1 do
begin
dot_prod := dot_prod + S_[(K) * dim[1] + (j)] * house_vec[j];
end;
for j := i + 1 to dim[1] - 1 do
begin
idx := (K) * dim[1] + (j);
S_[idx] := S_[idx] - dot_prod * house_vec[j];
end;
end;
// V(i,j) V_[(i)*dim[1]+(j)]
for K := 0 to dim[1] - 1 do
begin
dot_prod := 0;
for j := i + 1 to dim[1] - 1 do
begin
idx := (j) * dim[1] + (K);
dot_prod := dot_prod + V_[idx] * house_vec[j];
end;
for j := i + 1 to dim[1] - 1 do
begin
idx := (j) * dim[1] + (K);
V_[idx] := V_[idx] - dot_prod * house_vec[j];
end;
end;
end;
k0 := 0;
if (eps < 0) then
begin
eps := 1.0;
while (eps + 1.0 > 1.0) do
eps := eps * 0.5;
eps := eps * 64.0;
end;
while (k0 < dim[1] - 1) do
begin
S_max := 0.0;
for i := 0 to dim[1] - 1 do
begin
idx := (i) * dim[1] + (i);
S_max := Max(S_max, S_[idx]);
end;
while (k0 < dim[1] - 1) and (Abs(S_[(k0) * dim[1] + (k0 + 1)]) <= eps * S_max) do
Inc(k0);
if (k0 = (dim[1] - 1)) then
continue;
N := k0 + 2;
while (N < dim[1]) and (Abs(S_[(N - 1) * dim[1] + (N)]) > eps * S_max) do
Inc(N);
begin
idx := (N - 2) * dim[1] + (N - 2);
c[0][0] := Sqr(S_[idx]);
if (N - k0 > 2) then
begin
idx := (N - 3) * dim[1] + (N - 2);
c[0][0] := c[0][0] + Sqr(S_[idx]);
end;
idx := (N - 2) * dim[1] + (N - 2);
idx2 := (N - 2) * dim[1] + (N - 1);
c[0][1] := S_[idx] * S_[idx2];
c[1][0] := c[0][1];
idx := (N - 1) * dim[1] + (N - 1);
c[1][1] := Sqr(S_[idx]) + Sqr(S_[idx2]);
b := -(c[0][0] + c[1][1]) / 2;
c2 := c[0][0] * c[1][1] - c[0][1] * c[1][0];
d := 0;
if (b * b - c2 > 0) then
d := sqrt(b * b - c2)
else
begin
b := (c[0][0] - c[1][1]) / 2;
c2 := -c[0][1] * c[1][0];
if (b * b - c2 > 0) then
d := sqrt(b * b - c2);
end;
lambda1 := -b + d;
lambda2 := -b - d;
d1 := lambda1 - c[1][1];
if d1 < 0 then
d1 := -d1;
d2 := lambda2 - c[1][1];
if d2 < 0 then
d2 := -d2;
if d1 < d2 then
mu := lambda1
else
mu := lambda2;
idx := (k0) * dim[1] + (k0);
idx2 := (k0) * dim[1] + (k0 + 1);
alpha := Sqr(S_[idx]) - mu;
beta := S_[idx] * S_[idx2];
end;
for K := k0 to N - 2 do
begin
dimU := TArray<Integer>.Create(dim[0], dim[0]);
dimV := TArray<Integer>.Create(dim[1], dim[1]);
GivensR(S_, dim, K, alpha, beta);
GivensL(V_, dimV, K, alpha, beta);
idx := (K) * dim[1] + (K);
idx2 := (K + 1) * dim[1] + (K);
alpha := S_[idx];
beta := S_[idx2];
GivensL(S_, dim, K, alpha, beta);
GivensR(U_, dimU, K, alpha, beta);
idx := (K) * dim[1] + (K + 1);
alpha := S_[idx];
idx := (K) * dim[1] + (K + 2);
beta := S_[idx];
end;
begin
for i0 := k0 to N - 2 do
begin
for i1 := 0 to dim[1] - 1 do
begin
if (i0 > i1) or (i0 + 1 < i1) then
begin
idx := (i0) * dim[1] + (i1);
S_[idx] := 0;
end;
end;
end;
for i0 := 0 to dim[0] - 1 do
begin
for i1 := k0 to N - 2 do
begin
if (i0 > i1) or (i0 + 1 < i1) then
begin
idx := (i0) * dim[1] + (i1);
S_[idx] := 0;
end;
end;
end;
for i := 0 to dim[1] - 2 do
begin
idx := (i) * dim[1] + (i + 1);
if (Abs(S_[idx]) <= eps * S_max) then
begin
S_[idx] := 0;
end;
end;
end;
end;
end;
end.
|
{
Copyright (C) 2013-2021 Tim Sinaeve tim.sinaeve@gmail.com
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.
}
unit ts.RichEditor.Interfaces;
{$MODE DELPHI}
interface
uses
Classes, SysUtils, Forms, Controls, ComCtrls, Menus, ActnList, Graphics,
ts.RichEditor.Types;
{ All supported actions by the editor views, and holds a collection of all
registered views. }
type
IRichEditorActions = interface;
{ IRichEditorView }
IRichEditorView = interface
['{9F85A3C6-584D-497F-9C5C-7300D7AEF92E}']
{$REGION 'property access methods'}
function GetActions: IRichEditorActions;
function GetAlignCenter: Boolean;
function GetAlignJustify: Boolean;
function GetAlignLeft: Boolean;
function GetAlignRight: Boolean;
function GetCanPaste: Boolean;
function GetCanRedo: Boolean;
function GetCanUndo: Boolean;
function GetContentSize: Int64;
//function GetCurrentWord: string;
function GetEditor: TComponent;
function GetFileName: string;
function GetFont: TFont;
function GetForm: TCustomForm;
function GetIsEmpty: Boolean;
function GetIsFile: Boolean;
//function GetLinesInWindow: Integer;
//function GetLineText: string;
function GetModified: Boolean;
function GetOnChange: TNotifyEvent;
function GetOnDropFiles: TDropFilesEvent;
function GetPopupMenu: TPopupMenu;
function GetSelAvail: Boolean;
function GetSelEnd: Integer;
function GetSelStart: Integer;
function GetSelText: string;
function GetShowSpecialChars: Boolean;
function GetWordWrap: Boolean;
procedure SetAlignCenter(AValue: Boolean);
procedure SetAlignJustify(AValue: Boolean);
procedure SetAlignLeft(AValue: Boolean);
procedure SetAlignRight(AValue: Boolean);
//function GetSettings: IEditorSettings;
function GetText: string;
//function GetTextSize: Integer;
//function GetTopLine: Integer;
procedure SetFileName(const AValue: string);
procedure SetIsFile(AValue: Boolean);
//procedure SetLineText(const AValue: string);
procedure SetModified(const AValue: Boolean);
procedure SetOnChange(const AValue: TNotifyEvent);
procedure SetOnDropFiles(const AValue: TDropFilesEvent);
procedure SetParent(NewParent: TWinControl);
procedure SetPopupMenu(const AValue: TPopupMenu);
procedure SetSelEnd(const AValue: Integer);
procedure SetSelStart(const AValue: Integer);
procedure SetSelText(const AValue: string);
procedure SetShowSpecialChars(AValue: Boolean);
procedure SetText(const AValue: string);
procedure SetWordWrap(const AValue: Boolean);
//function GetAlignment: TParaAlignment;
//function GetBkColor: TColor;
//function GetColor: TColor;
//function GetHasBkColor: Boolean;
//function GetNumberingStyle: TParaNumStyle;
//procedure SetAlignment(AValue: TParaAlignment);
//procedure SetBkColor(AValue: TColor);
//procedure SetColor(const AValue: TColor);
//procedure SetHasBkColor(AValue: Boolean);
//procedure SetNumberingStyle(AValue: TParaNumStyle);
{$ENDREGION}
function Focused: Boolean;
procedure SetFocus;
procedure SelectAll;
procedure LoadFromFile(const AFileName: string);
procedure LoadFromStream(AStream: TStream);
procedure SaveToStream(AStream: TStream);
procedure SaveToFile(const AFileName: string);
procedure Load(const AStorageName: string = '');
procedure Save(const AStorageName: string = '');
procedure BeginUpdate;
procedure EndUpdate;
function IsUpdating: Boolean;
function InsertImage: Boolean; overload;
procedure InsertImageFile(const AFileName: string);
procedure InsertImage(AImage: TPicture); overload;
procedure InsertHyperlink(
const AText : string = '';
const AURL : string = ''
);
procedure InsertBulletList;
procedure InsertTextBox;
procedure IncIndent;
procedure DecIndent;
procedure AdjustParagraphStyle;
procedure Clear;
// clipboard commands
procedure Cut;
procedure Copy;
procedure Paste;
procedure Undo;
procedure Redo;
// properties
property Editor: TComponent
read GetEditor;
property Form: TCustomForm
read GetForm;
property Actions: IRichEditorActions
read GetActions;
property ContentSize: Int64
read GetContentSize;
property CanPaste: Boolean
read GetCanPaste;
property CanUndo: Boolean
read GetCanUndo;
property CanRedo: Boolean
read GetCanRedo;
{ Returns True if the view doesn't contain any data. }
property IsEmpty: Boolean
read GetIsEmpty;
property IsFile: Boolean
read GetIsFile write SetIsFile;
property Text: string
read GetText write SetText;
property SelText: string
read GetSelText write SetSelText;
property SelStart: Integer
read GetSelStart write SetSelStart;
property SelEnd: Integer
read GetSelEnd write SetSelEnd;
//property CurrentWord: string
// read GetCurrentWord;
//
property FileName: string
read GetFileName write SetFileName;
property Font: TFont
read GetFont;
property AlignLeft: Boolean
read GetAlignLeft write SetAlignLeft;
property AlignRight: Boolean
read GetAlignRight write SetAlignRight;
property AlignCenter: Boolean
read GetAlignCenter write SetAlignCenter;
property AlignJustify: Boolean
read GetAlignJustify write SetAlignJustify;
property SelAvail: Boolean
read GetSelAvail;
property Modified: Boolean
read GetModified write SetModified;
property OnDropFiles: TDropFilesEvent
read GetOnDropFiles write SetOnDropFiles;
property OnChange: TNotifyEvent
read GetOnChange write SetOnChange;
property WordWrap: Boolean
read GetWordWrap write SetWordWrap;
property ShowSpecialChars: Boolean
read GetShowSpecialChars write SetShowSpecialChars;
property PopupMenu: TPopupMenu
read GetPopupMenu write SetPopupMenu;
end;
{ Events dispatched by the editor view. }
IRichEditorEvents = interface
['{D078C92D-16DF-4727-A18F-4C76E07D37A2}']
{$REGION 'property access mehods'}
function GetOnAfterSave: TStorageEvent;
function GetOnBeforeSave: TStorageEvent;
function GetOnChange: TNotifyEvent;
function GetOnLoad: TStorageEvent;
function GetOnNew: TNewEvent;
function GetOnOpen: TStorageEvent;
procedure SetOnAfterSave(AValue: TStorageEvent);
procedure SetOnBeforeSave(AValue: TStorageEvent);
procedure SetOnChange(AValue: TNotifyEvent);
procedure SetOnLoad(AValue: TStorageEvent);
procedure SetOnNew(AValue: TNewEvent);
procedure SetOnOpen(AValue: TStorageEvent);
{$ENDREGION}
// event dispatch methods
procedure DoChange;
procedure DoOpen(const AName: string);
procedure DoBeforeSave(const AName: string);
procedure DoAfterSave(const AName: string);
procedure DoLoad(const AName: string);
procedure DoNew(
const AName : string = '';
const AText : string = ''
);
{ triggered when caret position changes }
property OnChange: TNotifyEvent
read GetOnChange write SetOnChange;
property OnLoad: TStorageEvent
read GetOnLoad write SetOnLoad;
property OnNew: TNewEvent
read GetOnNew write SetOnNew;
property OnOpen: TStorageEvent
read GetOnOpen write SetOnOpen;
property OnBeforeSave: TStorageEvent
read GetOnBeforeSave write SetOnBeforeSave;
property OnAfterSave: TStorageEvent
read GetOnAfterSave write SetOnAfterSave;
end;
IRichEditorActions = interface
['{E60C0187-4F9E-4585-B776-5B710B5498F9}']
{$REGION 'property access methods'}
function GetActions: TActionList;
function GetItem(AName: string): TContainedAction;
{$ENDREGION}
procedure UpdateActions;
property Items[AName: string]: TContainedAction
read GetItem; default;
property Actions: TActionList
read GetActions;
end;
IRichEditorManager = interface
['{A1781DE6-B022-4DBA-9D06-327E4612F65A}']
{$REGION 'property access methods'}
function GetEditorPopupMenu: TPopupMenu;
function GetActiveView: IRichEditorView;
function GetViewByName(AName: string): IRichEditorView;
procedure SetActiveView(const AValue: IRichEditorView);
function GetView(AIndex: Integer): IRichEditorView;
function GetViewCount: Integer;
{$ENDREGION}
function AddView(
const AName : string = '';
const AFileName : string = ''
): IRichEditorView;
function DeleteView(AIndex: Integer): Boolean;
procedure ClearViews;
property ActiveView: IRichEditorView
read GetActiveView write SetActiveView;
property EditorPopupMenu: TPopupMenu
read GetEditorPopupMenu;
property Views[AIndex: Integer]: IRichEditorView
read GetView;
property ViewByName[AName: string]: IRichEditorView
read GetViewByName;
property ViewCount: Integer
read GetViewCount;
end;
IRichEditorToolbarsFactory = interface
['{0C183975-86DE-4013-8D05-70879A07E775}']
function CreateMainToolbar(
AOwner : TComponent;
AParent : TWinControl
): TToolbar;
end;
IRichEditorMenusFactory = interface
['{13671A4F-9330-4A0A-B277-B052356DFE12}']
function CreateMainMenu(
AOwner : TComponent
): TMainMenu;
end;
implementation
end.
|
{-----------------------------------------------------------------------------
hpp_database (historypp project)
Version: 1.0
Created: 31.03.2003
Author: Oxygen
[ Description ]
Helper routines for database use
[ History ]
1.0 (31.03.2003) - Initial version
[ Modifications ]
[ Knows Inssues ]
None
Copyright (c) Art Fedorov, 2003
-----------------------------------------------------------------------------}
unit hpp_database;
interface
uses m_globaldefs, m_api, windows;
procedure SetSafetyMode(Safe: Boolean);
function DBGetContactSettingString(hContact: THandle; const szModule: PChar; const szSetting: PChar; ErrorValue: PChar): PChar;
function GetDBStr(const Module,Param: String; Default: String): String;
function GetDBInt(const Module,Param: String; Default: Integer): Integer;
function GetDBWord(const Module,Param: String; Default: Word): Word;
function GetDBDWord(const Module,Param: String; Default: DWord): DWord;
function GetDBByte(const Module,Param: String; Default: Byte): Byte;
function GetDBBool(const Module,Param: String; Default: Boolean): Boolean;
function WriteDBByte(const Module,Param: String; Value: Byte): Integer;
function WriteDBWord(const Module,Param: String; Value: Word): Integer;
function WriteDBDWord(const Module,Param: String; Value: DWord): Integer;
function WriteDBInt(const Module,Param: String; Value: Integer): Integer;
function WriteDBStr(const Module,Param: String; Value: String): Integer;
function WriteDBBool(const Module,Param: String; Value: Boolean): Integer;
implementation
{$I m_database.inc}
procedure SetSafetyMode(Safe: Boolean);
begin
PluginLink.CallService(MS_DB_SETSAFETYMODE,WPARAM(Safe),0);
end;
function WriteDBBool(const Module,Param: String; Value: Boolean): Integer;
begin
Result := WriteDBByte(Module,Param,Byte(Value));
end;
function WriteDBByte(const Module,Param: String; Value: Byte): Integer;
begin
Result := DBWriteContactSettingByte(0,PChar(Module),PChar(Param),Value);
end;
function WriteDBWord(const Module,Param: String; Value: Word): Integer;
begin
Result := DBWriteContactSettingWord(0,PChar(Module),PChar(Param),Value);
end;
function WriteDBDWord(const Module,Param: String; Value: DWord): Integer;
begin
Result := DBWriteContactSettingDWord(0,PChar(Module),PChar(Param),Value);
end;
function WriteDBInt(const Module,Param: String; Value: Integer): Integer;
var
cws: TDBCONTACTWRITESETTING;
begin
cws.szModule := PChar(Module);
cws.szSetting := PChar(Param);
cws.value.type_ := DBVT_DWORD;
cws.value.dVal := Value;
Result := PluginLink^.CallService(MS_DB_CONTACT_WRITESETTING, 0, lParam(@cws));
end;
function WriteDBStr(const Module,Param: String; Value: String): Integer;
begin
Result := DBWriteContactSettingString(0,PChar(Module),PChar(Param),PChar(Value));
end;
function GetDBBool(const Module,Param: String; Default: Boolean): Boolean;
begin
Result := Boolean(GetDBByte(Module,Param,Byte(Default)));
end;
function GetDBByte(const Module,Param: String; Default: Byte): Byte;
begin
Result := DBGetContactSettingByte(0,PChar(Module),PChar(Param),Default);
end;
function GetDBWord(const Module,Param: String; Default: Word): Word;
begin
Result := DBGetContactSettingWord(0,PChar(Module),PChar(Param),Default);
end;
function GetDBDWord(const Module,Param: String; Default: DWord): DWord;
begin
Result := DBGetContactSettingDWord(0,PChar(Module),PChar(Param),Default);
end;
function GetDBInt(const Module,Param: String; Default: Integer): Integer;
var
cws:TDBCONTACTGETSETTING;
dbv:TDBVariant;
begin
dbv.type_ := DBVT_DWORD;
dbv.dVal:=Default;
cws.szModule:=PChar(Module);
cws.szSetting:=PChar(Param);
cws.pValue:=@dbv;
if PluginLink.CallService(MS_DB_CONTACT_GETSETTING,0,DWord(@cws))<>0 then
Result:=default
else
Result:=dbv.dval;
end;
function GetDBStr(const Module,Param: String; Default: String): String;
begin
Result := DBGetContactSettingString(0,PChar(Module),PChar(Param),PChar(Default));
end;
function DBGetContactSettingString(hContact: THandle; const szModule: PChar; const szSetting: PChar; ErrorValue: PChar): PChar;
var
dbv: TDBVARIANT;
cgs: TDBCONTACTGETSETTING;
begin
cgs.szModule := szModule;
cgs.szSetting := szSetting;
cgs.pValue := @dbv;
if PluginLink^.CallService(MS_DB_CONTACT_GETSETTING, hContact, lParam(@cgs)) <> 0 then
Result := ErrorValue
else
Result := dbv.pszVal;
end;
end.
|
unit liEngine;
interface
uses
l3Types,
l3Interfaces,
l3Base,
l3DatLst,
l3Filer
;
const
cLastColumn = 'X';
type
TListRow = array['A'..cLastColumn] of Il3CString;
TListImporter = class(Tl3Base)
private
f_FileName: string;
f_Header: TListRow;
f_OnProgress: Tl3ProgressProc;
procedure LoadRow(aFiler: Tl3CustomFiler; var theRow: TListRow);
function pm_GetHeader(Index: Char): Il3CString;
function GetRowString(const aRow: TListRow): Il3CString;
protected
public
constructor Create(aFileName: string);
procedure Process;
function ProcessRow(var aRow: TListRow): Boolean;
property FileName: string read f_FileName write f_FileName;
property Header[Index: Char]: Il3CString read pm_GetHeader;
property OnProgress: Tl3ProgressProc read f_OnProgress write f_OnProgress;
end;
implementation
uses
Classes,
l3Date,
l3String,
l3Tree_TLB,
l3Nodes,
l3TreeInterfaces,
l3DateSt,
l3FileUtils,
SysUtils,
StrUtils,
JclStrings,
daInterfaces,
daTypes,
daSchemeConsts,
DT_Types,
DT_Const,
DT_Serv,
DT_Doc,
Dt_ReNum,
Dt_Free,
DT_Dict,
dt_TblCacheDef,
DT_LinkServ,
DT_DocImages,
DT_TblCache,
dt_AttrSchema,
DT_DictConst,
DT_Record;
constructor TListImporter.Create(aFileName: string);
begin
inherited Create;
f_FileName := aFileName;
end;
procedure TListImporter.LoadRow(aFiler: Tl3CustomFiler; var theRow: TListRow);
var
l_SrcString: Tl3WString;
C: Char;
l_Offset: Integer;
l_WordEnd: Integer;
begin
l_SrcString := l3Trim(aFiler.ReadLn);
Finalize(theRow);
if not l3IsNil(l_SrcString) then
begin
C := 'A';
l_Offset := 0;
l_WordEnd := 0;
while l_WordEnd < l_SrcString.SLen do
begin
if l_SrcString.S[l_WordEnd] = ';' then
begin
if l_WordEnd > l_Offset then
theRow[C] := l3CStr(l3Trim(l3PCharLen(l_SrcString.S + l_Offset, l_WordEnd - l_Offset, l_SrcString.SCodePage)));
Inc(C);
if C > cLastColumn then
Break;
l_Offset := l_WordEnd + 1;
end;
Inc(l_WordEnd);
end;
end;
end;
function TListImporter.pm_GetHeader(Index: Char): Il3CString;
begin
Result := f_Header[Index];
end;
procedure TListImporter.Process;
var
I: Integer;
l_Row: TListRow;
l_Dest, l_Src: Tl3DOSFiler;
l_TempFName: string;
begin
l_Src := Tl3DOSFiler.Make(f_FileName, l3_fmRead);
try
l_Src.Indicator.NeedProgressProc := True;
l_Src.Indicator.OnProgressProc := f_OnProgress;
l_Src.Open;
LoadRow(l_Src, f_Header);
l_TempFName := ChangeFileExt(f_FileName, '.processed.csv');
l_Dest := Tl3DOSFiler.Make(l_TempFName, l3_fmWrite);
try
l_Dest.Open;
l_Dest.WriteLn(GetRowString(f_Header).AsWStr);
while not l_Src.EOF do
begin
LoadRow(l_Src, l_Row);
ProcessRow(l_Row);
l_Dest.WriteLn(GetRowString(l_Row).AsWStr);
end;
finally
l3Free(l_Dest);
end;
finally
l3Free(l_Src);;
end;
RenameFileSafe(l_TempFName, f_FileName);
end;
function TListImporter.ProcessRow(var aRow: TListRow): Boolean;
var
l_DocID: TDocID;
l_RealDocID: TDocID;
l_IsNewDoc: Boolean;
l_Free: TFreeTbl;
l_FileTbl: TFileTbl;
l_FullName: Tl3WString;
l_Rec: TdtRecord;
l_DNCache : TCacheDiffAttrData;
l_Filename: string;
l_SourceIDs: array[0..1] of TDictID;
l_Type: Byte;
l_AbsNum: Integer;
l_StartDate, l_EndDate: TStDate;
procedure AddToX(const aStr: string);
begin
if not l3IsNil(aRow['X']) then
aRow['X'] := l3Cat(aRow['X'], ', ');
aRow['X'] := l3Cat(aRow['X'], aStr);
end;
procedure GetDN(aDNType: TDNType; aNumCol, aDateCol: Char);
var
l_Date: TStDate;
l_Num : Tl3String;
begin
if (not l3IsNil(aRow[aNumCol])) or (not l3IsNil(aRow[aDateCol])) then
begin
l_Num := nil;
l3Set(l_Num, aRow[aNumCol]);
try
if not l3IsNil(aRow[aDateCol]) then
begin
l_Date := DateTimeToStDate(l3Date.StrToDateDef(l3PCharLen2String(aRow[aDateCol].AsWStr), BadDateTime));
if l_Date = BadDate then
begin
AddToX('Некорректая дата (столбец "'+aDateCol+'")');
Exit;
end;
end;
l_DNCache.AddRecord([l_RealDocID,
l_Date,
l_Num,
Ord(aDNType),
Tl3String(nil),
0]);
finally
l3Free(l_Num);
end;
end;
end;
procedure AddLinkToDict(aDict: TdaDictionaryType; aCol: Char);
var
l_DictRoot: TDictRootNode;
l_Node : Il3Node;
l_HNode: Il3HandleNode;
l_LinkData: TSublinkDataRec;
function IterDict(const CurNode : Il3Node): Boolean;
begin
Result := AnsiContainsText(l3Str(CurNode.Text), l3Str(aRow[aCol])); /// НЕХОРОШО!
end;
begin
if not l3IsNil(aRow[aCol]) then
begin
l_DictRoot := DictServer(CurrentFamily).DictRootNode[aDict].Use;
try
l_Node := l3IterateSubTreeF(l_DictRoot, l3L2NA(@IterDict), imCheckResult or imLeavesOnly);
if l_Node <> nil then
begin
if l3IOk(l_Node.QueryInterface(Il3HandleNode,l_HNode)) then
begin
l_LinkData.DictID := l_HNode.Handle;
l_LinkData.SubID := 0;
LinkServer(CurrentFamily).Links[aDict].AddNode(l_RealDocID, l_LinkData);
end;
end
else
AddToX('Некорректное значение в столбце "' + l3Str(Header[aCol]) + '"');
finally
l3Free(l_DictRoot);
end;
end;
end;
begin
Result := True;
try
aRow['X'] := nil; // обнулим лог ошибок
// надо ли вообще обрабатывать?
if not l3IsNil(aRow['U']) then
begin
aRow['X'] := l3CStr('Строка пропущена');
Exit;
end;
DocumentServer.Family := CurrentFamily;
l_FileTbl := DocumentServer.FileTbl;
// выясняем номер топика
// сначала попробуем создать новый документ
l_IsNewDoc := False;
l_DocID := cUndefDocID;
l_RealDocID := cUndefDocID;
if not l3IsNil(aRow['S']) then
begin
l_DocID := l3StrToIntDef(aRow['S'].AsWStr, -1);
if l_DocID = -1 then
begin
aRow['X'] := l3CStr('Ошибка в номере топика (S)');
Result := False;
Exit;
end;
// получаем внутренний id топика
l_RealDocID := LinkServer(CurrentFamily).Renum.ConvertToRealNumber(l_DocID);
// если такой документ уже есть, то отказать в обработке
if (l_RealDocID <> cUndefDocID) and l_FileTbl.CheckDoc(l_RealDocID) then
begin
aRow['X'] := l3CStr('Повтор топика');
Result := False;
Exit;
end;
l_RealDocID := l_DocID;
LinkServer(CurrentFamily).Renum.GetRNumber(l_RealDocID); // заводим связку Ext-Int
l_IsNewDoc := True;
end;
// Новый документ создавать, возможно, не надо. Возможно, надо модифицировать существующий?
if l_RealDocID = cUndefDocID then
begin
if not l3IsNil(aRow['T']) then
begin
l_DocID := l3StrToIntDef(aRow['T'].AsWStr, -1);
if l_DocID = -1 then
begin
aRow['X'] := l3CStr('Ошибка в номере топика (T)');
Result := False;
Exit;
end;
// получаем внутренний id топика
l_RealDocID := LinkServer(CurrentFamily).Renum.ConvertToRealNumber(l_DocID);
// если такого документа нет, то отказать в обработке
if (l_RealDocID = cUndefDocID) or (not l_FileTbl.CheckDoc(l_RealDocID)) then
begin
aRow['X'] := l3CStr('Нет топика');
Result := False;
Exit;
end;
end;
end;
// Номер топика явно не указан. Создаем документ с номером из диапазона.
if l_RealDocID = cUndefDocID then
begin
l_Free := GlobalHtServer.FreeTbl[CurrentFamily];
repeat
l_DocID := l_Free.GetFree(ftnDocIDForLists); // если не получится, вылетим по эксепшену и поймаем его ниже
l_RealDocID := LinkServer(CurrentFamily).Renum.ConvertToRealNumber(l_DocID);
until (l_RealDocID = cUndefDocID) or (not l_FileTbl.CheckDoc(l_RealDocID));
l_RealDocID := l_DocID;
LinkServer(CurrentFamily).Renum.GetRNumber(l_RealDocID); // заводим связку Ext-Int
l_IsNewDoc := True;
end;
if l_RealDocID = cUndefDocID then // на всякий случай
begin
aRow['X'] := l3CStr('Ошибка определения номера топика');
Result := False;
Exit;
end;
if l_IsNewDoc then // создаем новый документ
begin
l_Rec := InitRecord(l_FileTbl);
l_Rec.FillField(fId_Fld, [l_RealDocID]);
l_Type := Ord(dtText);
l_Rec.FillField(fType_Fld, [l_Type]);
end
else // подгружаем данные о существующем
l_FileTbl.CheckDoc(l_RealDocID, @l_Rec);
// заполняем атрибуты документа значениями из реестра
if not l3IsNil(aRow['E']) then
begin
l_Rec.FillField(fFName_Fld, [aRow['E']]);
end;
// для дальнейших операций нужно иметь актуальный документ
l_Rec.Update;
l_DNCache := TCacheDiffAttrData.Create(CurrentFamily, ctDateNum);
try
l_DNCache.CachingMode := cmAddOnly;
GetDN(dnPublish, 'C', 'D');
GetDN(dnMU, 'F', 'G');
l_DNCache.CloseDoc(l_RealDocID);
finally
l3Free(l_DNCache);
end;
AddLinkToDict(da_dlTypes, 'A');
AddLinkToDict(da_dlSources, 'B');
// смотрим образ документа
if not l3IsNil(aRow['Q']) then
begin
if DirectoryExists(l3Str(aRow['R'])) then
begin
l_Filename := ConcatDirName(l3Str(aRow['R']), l3Str(aRow['Q']));
if FileExists(l_Filename) then
begin
if not l3IsNil(aRow['J']) then
l_SourceIDs[0] := DictServer(CurrentFamily).Dict[da_dlCorSources].FindIDByFullPath(aRow['J'].AsWStr)
else
l_SourceIDs[0] := cUndefDictID;
if l_SourceIDs[0] <> cUndefDictID then
begin
l_SourceIDs[1] := 0;
l_StartDate := 0;
l_EndDate := 0;
l3StrToDateInterval(l3Str(aRow['L']), l_StartDate, l_EndDate);
DocImageServer.Add(l_RealDocID,
l_Filename,
l_SourceIDs,
'',
l3Str(aRow['K']),
l_StartDate,
l_EndDate);//,
//True, True);
end
else
AddToX('Не найден источник "' + l3Str(aRow['J']) + '"');
end
else
AddToX('Не найден файл '+l_Filename);
end
else
AddToX('Не найден каталог ' + l3Str(aRow['R']));
end;
except
on E: Exception do
begin
AddToX(E.Message);
Result := False;
end;
end;
end;
function TListImporter.GetRowString(const aRow: TListRow): Il3CString;
var
C: Char;
begin
Result := nil;
for C := 'A' to 'X' do
begin
Result := l3Cat([Result, aRow[C]]);
if C <> 'X' then
Result := l3Cat(Result, ';');
end;
end;
end.
|
unit Script.Interfaces;
interface
type
IscriptLog = interface
procedure Log(const aString: String);
end;//IscriptLog
implementation
end.
|
unit socket.io;
interface
uses
NodeJS.Core, NodeJS.http,
socket.io.Core;
type
JSocketIO = class;
JSocketNamespace = class;
JSocketManager = class;
JSocketIOSocketFunction = procedure(aSocket: JSocketIO);
JSocketIODataFunction = procedure(aData: variant);
JSocketIODataFnFunction = procedure(aData: variant; fn: JSocketIODataFunction);
JSocketIO = class external "Object"
public
function &in(room: string): JSocketIO;
function &to(room: string): JSocketIO;
function join(name: string; fn: JFunction): JSocketIO;
function unjoin(name: string; fn: JFunction): JSocketIO;
function &set(key: string; value: variant; fn: JFunction): JSocketIO;
function get(key: string; value: variant; fn: JFunction): JSocketIO;
function has(key: string; fn: JFunction): JSocketIO;
function del(key: string; fn: JFunction): JSocketIO;
function disconnect(): JSocketIO;
function send(data: variant; fn: JFunction): JSocketIO;
function emit(ev: variant; data: array of variant): JSocketIO;
function &on(ns: string; fn: JSocketIODataFnFunction): JSocketIO;
property json: variant;
property log: variant;
property volatile: variant;
property broadcast: variant;
end;
JSocketNamespace = class external "Object"
public
function clients(room: string): array of JSocketIO;
function &in(room: string): JSocketNamespace;
function &on(evt: string; fn: JSocketIOSocketFunction): JSocketNamespace;
function &to(room: string): JSocketNamespace;
function &except(id: variant): JSocketNamespace;
function send(data: variant): variant;
function emit(ev: variant; data: array of variant): JSocketIO;
function socket(sid: variant; readable: boolean): JSocketIO;
procedure authorization(fn: JFunction);
property log: variant;
property store: variant;
property json: variant;
property volatile: variant;
end;
JSocketManager = class external "Object"
public
function get(key: variant): variant;
function set(key: variant; value: variant): JSocketManager;
function enable(key: variant): JSocketManager;
function disable(key: variant): JSocketManager;
function enabled(key: variant): boolean;
function disabled(key: variant): boolean;
function configure(env: string; fn: JFunction): JSocketManager;overload;
function configure(fn: JFunction): JSocketManager;overload;
function &of(nsp: string): JSocketNamespace;
function &on(ns: string; fn: JFunction): JSocketManager;
property sockets: JSocketNamespace;
end;
Jsocket_io_Exports = class external
public
//function listen(server: JServer; options: variant; fn: JFunction): JSocketManager;overload;external;
//function listen(server: JServer; fn: JFunction): JSocketManager;overload;external;
function listen(server: JServer): JSocketManager;overload;external;
//function listen(port: JNumber): JSocketManager;overload;external;
end;
function socketio: Jsocket_io_Exports;
implementation
uses
Nodejs.core;
function socketio: Jsocket_io_Exports;
begin
Result := Jsocket_io_Exports( require('socket.io') );
end;
end.
|
unit ActionTypeControl;
interface
uses
TypeControl;
const
_ACTION_UNKNOWN_ : LongInt = -1;
ACTION_NONE : LongInt = 0;
ACTION_CLEAR_AND_SELECT : LongInt = 1;
ACTION_ADD_TO_SELECTION : LongInt = 2;
ACTION_DESELECT : LongInt = 3;
ACTION_ASSIGN : LongInt = 4;
ACTION_DISMISS : LongInt = 5;
ACTION_DISBAND : LongInt = 6;
ACTION_MOVE : LongInt = 7;
ACTION_ROTATE : LongInt = 8;
ACTION_SCALE : LongInt = 9;
ACTION_SETUP_VEHICLE_PRODUCTION: LongInt = 10;
ACTION_TACTICAL_NUCLEAR_STRIKE : LongInt = 11;
_ACTION_COUNT_ : LongInt = 12;
type
TActionType = LongInt;
TActionTypeArray = TLongIntArray;
TActionTypeArray2D = TLongIntArray2D;
TActionTypeArray3D = TLongIntArray3D;
TActionTypeArray4D = TLongIntArray4D;
TActionTypeArray5D = TLongIntArray5D;
implementation
end.
|
unit Unit2;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, System.JSON,
FMX.Objects, FMX.ScrollBox, FMX.Memo, FMX.StdCtrls, FMX.Edit,
FMX.Controls.Presentation, FMX.ListBox, FMX.Layouts, REST.Types,
FireDAC.Stan.Intf, FireDAC.Stan.Option, FireDAC.Stan.Param,
FireDAC.Stan.Error, FireDAC.DatS, FireDAC.Phys.Intf, FireDAC.DApt.Intf,
Data.DB, FireDAC.Comp.DataSet, FireDAC.Comp.Client, REST.Response.Adapter,
REST.Client, System.NetEncoding, Data.Bind.Components, Data.Bind.ObjectScope, IdCoderMIME,
EncdDecd, redis.client,
redis.commons,
redis.netlib.indy,
System.Threading;
type
TEventReturn = procedure (Channel, Message : String) of Object;
TForm2 = class(TForm)
Layout1: TLayout;
Layout2: TLayout;
ListBox1: TListBox;
ListBoxItem1: TListBoxItem;
Label1: TLabel;
edtReferenceId: TEdit;
ListBoxItem2: TListBoxItem;
Label2: TLabel;
edtproductName: TEdit;
ListBoxItem3: TListBoxItem;
Label3: TLabel;
edtvalue: TEdit;
ListBoxItem4: TListBoxItem;
Label4: TLabel;
edtfirstName: TEdit;
ListBoxItem5: TListBoxItem;
Label5: TLabel;
edtlastName: TEdit;
ListBoxItem6: TListBoxItem;
Label6: TLabel;
edtdocument: TEdit;
ListBoxItem7: TListBoxItem;
Label7: TLabel;
edtemail: TEdit;
ListBoxItem8: TListBoxItem;
Label8: TLabel;
edtphone: TEdit;
Button1: TButton;
Layout3: TLayout;
Memo1: TMemo;
Layout4: TLayout;
Layout5: TLayout;
Layout6: TLayout;
RESTClient1: TRESTClient;
RESTRequest1: TRESTRequest;
RESTResponse1: TRESTResponse;
RESTResponseDataSetAdapter1: TRESTResponseDataSetAdapter;
FDMemTable1: TFDMemTable;
Image1: TImage;
Rectangle1: TRectangle;
Label9: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
_redis: IRedisClient;
FClosing : Boolean;
FTask: ITask;
public
{ Public declarations }
procedure onStatusPayment(channel, message : String);
procedure RegistryAction(Channel : String; Metodo : TEventReturn);
function BitmapFromBase64(base64: string): TBitmap;
end;
var
Form2: TForm2;
implementation
{$R *.fmx}
procedure TForm2.Button1Click(Sender: TObject);
var
JsonPicPay: TJsonObject;
begin
JsonPicPay := TJsonObject.Create;
try
JsonPicPay
.AddPair('referenceId', edtReferenceId.Text)
.AddPair('productName', edtproductName.Text)
.AddPair('value', TJSONNumber.Create(StrToFloat(edtvalue.Text)))
.AddPair('firstName', edtfirstName.Text)
.AddPair('lastName', edtlastName.Text)
.AddPair('document', edtdocument.Text)
.AddPair('email', edtemail.Text)
.AddPair('phone', edtphone.Text);
RESTRequest1.Body.ClearBody;
RESTRequest1.Body.Add(JsonPicPay.ToJSON, ctAPPLICATION_JSON);
RESTRequest1.Execute;
try
BitmapFromBase64(FDMemTable1.FieldByName('qrcodeBase64').AsString);
RegistryAction(edtReferenceId.Text, onStatusPayment);
except
ShowMessage(
FDMemTable1.FieldByName('error').AsString
);
end;
finally
JsonPicPay.Free;
end;
end;
procedure TForm2.FormCreate(Sender: TObject);
begin
_redis := NewRedisClient('52.36.56.222', 6379);
FClosing := False;
end;
procedure TForm2.FormDestroy(Sender: TObject);
begin
FClosing := True;
end;
procedure TForm2.onStatusPayment(channel, message: String);
begin
if message = 'paid' then
begin
Rectangle1.Fill.Color := TAlphaColor($FF008000);
Label9.Text := 'Pagamento Realizado com Sucesso';
end
else
begin
Rectangle1.Fill.Color := TAlphaColor($FFff0000);
Label9.Text := 'Erro ao Realizar Pagamento';
end;
end;
function TForm2.BitmapFromBase64(base64: string): TBitmap;
var
Input: TStringStream;
Output: TBytesStream;
begin
base64 := stringreplace(base64, 'data:image/png;base64,', '', [rfReplaceAll]);
Input := TStringStream.Create(base64, TEncoding.ASCII);
try
Output := TBytesStream.Create;
try
DecodeStream(Input, Output);
Output.Position := 0;
try
Image1.Bitmap.LoadFromStream(Output);
except
raise;
end;
finally
Output.Free;
end;
finally
Input.Free;
end;
end;
procedure TForm2.RegistryAction(Channel : String; Metodo : TEventReturn);
begin
FTask := TTask.Run(
procedure
var
r: IRedisClient;
begin
r := NewRedisClient('52.36.56.222', 6379);
r.SUBSCRIBE([Channel],
procedure(Channel : String; message : string)
begin
TThread.Synchronize(nil,
procedure
begin
Metodo(channel, message);
end);
end,
function: Boolean
begin
Result := Assigned(Self) and (not FClosing);
end);
end);
end;
end.
|
PROGRAM Tree;
TYPE
NodePtr = ^Node;
Node = RECORD
value: INTEGER;
left: NodePtr;
right: NodePtr;
END;
TreePtr = NodePtr;
FUNCTION InitTree: TreePtr;
BEGIN
InitTree := NIL;
END;
FUNCTION NewNode(value: INTEGER): NodePtr;
VAR
n: NodePtr;
BEGIN
New(n);
n^.value := value;
n^.left := NIL;
n^.right := NIL;
NewNode := n;
END;
(* n , left, right *)
FUNCTION TreeOf(n: NodePtr; l,r: TreePtr): TreePtr;
BEGIN
IF n <> NIL THEN BEGIN
n^.left := l;
n^.right := r;
TreeOf := n;
END;
END;
PROCEDURE WriteTreeInOrder(t: TreePtr);
BEGIN
IF t <> NIL THEN BEGIN
WriteTreeInOrder(t^.left);
Write(t^.value);
WriteTreeInOrder(t^.right);
END;
END;
PROCEDURE WriteGrafik(level: INTEGER; t: TreePtr);
BEGIN
IF t <> NIL THEN BEGIN
WriteGrafik(level + 4, t^.left);
WriteLn(' ':level,'|',t^.value);
WriteGrafik(level + 4, t^.right);
END;
END;
FUNCTION CountNrOf(t: TreePtr; value: INTEGER): INTEGER;
BEGIN
IF t = NIL THEN
CountNrOf := 0
ELSE BEGIN
IF t^.value = value THEN
CountNrOf := 1 + CountNrOf(t^.left,value) + CountNrOf(t^.right,value)
ELSE
CountNrOf := CountNrOf(t^.left,value) + CountNrOf(t^.right,value);
END;
END;
Function InnerNodes(t: TreePtr): INTEGER;
BEGIN
IF (t = NIL) OR ((t^.left = NIL) AND (t^.right = NIL)) THEN
InnerNodes := 0
ELSE
InnerNodes := 1 + InnerNodes(t^.left) + InnerNodes(t^.right);
END;
FUNCTION CountNodes(t: TreePtr): INTEGER;
BEGIN
IF t = NIL THEN
CountNodes := 0
ELSE
CountNodes := 1 + CountNodes(t^.left) + CountNodes(t^.right);
END;
PROCEDURE Replace(t: TreePtr; value: INTEGER; VAR found: BOOLEAN);
BEGIN
IF (t <> NIL) AND not(found) THEN BEGIN
Replace(t^.left,value,found);
IF t^.value = value THEN BEGIN
//found := TRUE;
t^.value := 99;
END;
Replace(t^.right,value,found);
END;
END;
FUNCTION Level(t: TreePtr; lev: INTEGER): INTEGER;
VAR
count: INTEGER;
BEGIN
count := 0;
IF t^.left^.right <> NIL THEN
count := count + 1;
IF t^.left^.left <> NIL THEN
count := count + 1;
IF t^.right^.right <> NIL THEN
count := count + 1;
IF t^.right^.left <> NIL THEN
count := count + 1;
Level := count;
END;
VAR
t: TreePtr;
lev: INTEGER;
found: BOOLEAN;
BEGIN
found := FALSE;
lev := 0;
t := InitTree;
t := TreeOf(NewNode(5),
TreeOf(NewNode(3),NewNode(2),NewNode(4)),TreeOf(NewNode(2), NIL, TreeOf(NewNode(2), NIL, NewNode(2))));
WriteTreeInOrder(t);
WriteLn;
WriteGrafik(lev,t);
WriteLn;
WriteLn('Anzahl von Zahl 2 in Baum: ', CountNrOf(t,2));
WriteLn;
Replace(t,2,found);
WriteGrafik(lev,t);
WriteLn('inner Nodes: ',InnerNodes(t));
WriteLn('alle nodes: ', CountNodes(t));
WriteLn;
WriteLn('level 3: ', Level(t,3));
END. |
{
Clever Internet Suite
Copyright (C) 2013 Clever Components
All Rights Reserved
www.CleverComponents.com
}
unit clImapFetch;
interface
{$I clVer.inc}
uses
{$IFNDEF DELPHIXE2}
Classes, SysUtils, Contnrs,
{$ELSE}
System.Classes, System.SysUtils, System.Contnrs,
{$ENDIF}
clMailMessage, clMailHeader;
type
TclImap4FetchEnvelope = class
private
class function Normalize(const ASource: string): string;
class function GetField(AFieldList: TclMailHeaderFieldList; const AName: string): string;
class function GetSubjectField(AFieldList: TclMailHeaderFieldList): string;
class function GetMBName(const AEmail: string): string;
class function GetDName(const AEmail: string): string;
class function GetMails(AFieldList: TclMailHeaderFieldList; const AName: string): string;
class function NormalizeName(const ASource: string): string;
public
class procedure Build(AMessage: TStrings; AResponse: TStream);
end;
TclImap4FetchBodyStructure = class
private
class procedure GetUueBodySize(AMessage: TStrings; var ASize, ALines: Integer);
class function GetMimeBodySize(ABody: TclMessageBody): string;
class function GetMimeBodyStructure(ABodies: TclMessageBodies): string;
class procedure ExtractContentTypeParts(const AContentType: string; var AType, ASubType: string);
public
class procedure Build(AMessage: TStrings; AResponse: TStream);
end;
TclImap4FetchBody = class
private
class procedure BuildBodyPartTitle(const ACommand: string; ADataSize: Integer; AResponse: TStream);
class procedure BuildBodyContent(AMessage: TStrings; ABody: TclMessageBody;
const ACommand: string; AResponse: TStream; AReturnHeader: Boolean);
class function BuildTextBody(AMessage: TStrings; ABodies: TclMessageBodies;
const ACommand: string; AResponse: TStream): Boolean;
class procedure BuildBodyFields(AMessage: TStrings; ABody: TclMessageBody;
const ACommand, AFetchFields: string; AResponse: TStream; isNot: Boolean);
class procedure BuildBodyPart(AMessage: TStrings; ABodies: TclMessageBodies; AParent: TclMessageBody;
const ACommand: string; ABodyPart: TStrings; AResponse: TStream);
public
class procedure Build(AMessage: TStrings; const ACommand, ABodyPart: string; AResponse: TStream);
end;
TclImap4FetchItem = class
private
FName: string;
FPartial: string;
FSection: string;
public
constructor Create(const AName: string);
property Name: string read FName write FName;
property Section: string read FSection write FSection;
property Partial: string read FPartial write FPartial;
end;
TclImap4FetchList = class
private
FList: TObjectList;
function GetCount: Integer;
function GetItem(Index: Integer): TclImap4FetchItem;
procedure ParseDataItems(const ASource: string);
procedure ParseBodyStructure;
procedure ParseMacros;
public
constructor Create;
destructor Destroy; override;
procedure Parse(const ASource: string); virtual;
procedure Add(AItem: TclImap4FetchItem);
procedure Delete(Index: Integer);
procedure Clear;
property Items[Index: Integer]: TclImap4FetchItem read GetItem; default;
property Count: Integer read GetCount;
end;
implementation
uses
clUtils, clEmailAddress, clEncoder, clWUtils, clTranslator;
const
EncodingMap: array[TclEncodeMethod] of string = ('"7bit"', '"quoted-printable"', '"base64"', 'NIL', '"8bit"');
{ TclImap4FetchEnvelope }
class procedure TclImap4FetchEnvelope.Build(AMessage: TStrings; AResponse: TStream);
var
fieldList: TclMailHeaderFieldList;
from, sender, result: string;
buf: TclByteArray;
begin
{$IFNDEF DELPHI2005}buf := nil;{$ENDIF}
fieldList := TclMailHeaderFieldList.Create(DefaultCharSet, cmNone, DefaultCharsPerLine);
try
fieldList.Parse(0, AMessage);
result := GetField(fieldList, 'Date') + #32;
result := result + GetSubjectField(fieldList) + #32;
from := GetMails(fieldList, 'From');
result := result + from + #32;
sender := GetMails(fieldList, 'Sender');
if (sender = 'NIL') then
begin
sender := from;
end;
result := result + sender + #32;
result := result + GetMails(fieldList, 'Reply-To') + #32;
result := result + GetMails(fieldList, 'To') + #32;
result := result + GetMails(fieldList, 'Cc') + #32;
result := result + GetMails(fieldList, 'Bcc') + #32;
result := result + 'NIL'#32;
result := result + GetField(fieldList, 'Message-ID');
result := 'ENVELOPE (' + result + ')';
buf := TclTranslator.GetBytes(result);
AResponse.Write(buf[0], Length(buf));
finally
fieldList.Free();
end;
end;
class function TclImap4FetchEnvelope.GetDName(const AEmail: string): string;
var
ind: Integer;
begin
Result := AEmail;
ind := system.Pos('@', AEmail);
if (ind > 0) then
begin
Result := system.Copy(AEmail, ind + 1, Length(AEmail));
end;
end;
class function TclImap4FetchEnvelope.GetField(AFieldList: TclMailHeaderFieldList; const AName: string): string;
begin
Result := Normalize(AFieldList.GetFieldValue(AName));
end;
class function TclImap4FetchEnvelope.GetSubjectField(AFieldList: TclMailHeaderFieldList): string;
begin
Result := GetQuotedString(AFieldList.GetFieldValue('Subject'));
end;
class function TclImap4FetchEnvelope.GetMails(AFieldList: TclMailHeaderFieldList; const AName: string): string;
var
i: Integer;
list: TStrings;
addr: TclEmailAddressItem;
begin
Result := '';
list := nil;
addr := nil;
try
list := TStringList.Create();
addr := TclEmailAddressItem.Create();
list.Text := StringReplace(AFieldList.GetFieldValue(AName), ',', #13#10, [rfReplaceAll]);
for i := 0 to list.Count - 1 do
begin
addr.FullAddress := list[i];
Result := Result + '(' + NormalizeName(addr.Name) + #32'NIL'#32 + Normalize(GetMBName(addr.Email)) + #32
+ Normalize(GetDName(addr.Email)) + ')';
end;
finally
addr.Free();
list.Free();
end;
if (Result = '') then
begin
Result := 'NIL';
end else
begin
Result := '(' + Result + ')';
end;
end;
class function TclImap4FetchEnvelope.GetMBName(const AEmail: string): string;
var
ind: Integer;
begin
Result := '';
ind := system.Pos('@', AEmail);
if (ind > 0) then
begin
Result := system.Copy(AEmail, 1, ind - 1);
end;
end;
class function TclImap4FetchEnvelope.Normalize(const ASource: string): string;
begin
if (ASource = '') then
begin
Result := 'NIL';
end else
begin
Result := '"' + ASource + '"';
end;
end;
class function TclImap4FetchEnvelope.NormalizeName(const ASource: string): string;
begin
if (ASource = '') then
begin
Result := 'NIL';
end else
begin
Result := '{' + IntToStr(Length(ASource)) + '}'#13#10 + ASource;
end;
end;
{ TclImap4FetchBodyStructure }
class procedure TclImap4FetchBodyStructure.Build(AMessage: TStrings; AResponse: TStream);
var
msg: TclMailMessage;
cntType, subType, result: string;
size, lines: Integer;
buf: TclByteArray;
begin
{$IFNDEF DELPHI2005}buf := nil;{$ENDIF}
msg := TclMailMessage.Create(nil);
try
msg.MessageSource := AMessage;
if (msg.MessageFormat = mfUUencode) then
begin
GetUueBodySize(AMessage, size, lines);
result := Format('"TEXT" "PLAIN" NIL NIL NIL "7BIT" %d %d NIL NIL NIL', [size, lines]);
end else
begin
result := GetMimeBodyStructure(msg.Bodies);
if (msg.Bodies.Count > 1) and (msg.Boundary <> '') then
begin
ExtractContentTypeParts(msg.ContentType, cntType, subType);
cntType := '';
if (msg.ContentSubType <> '') then
begin
cntType := Format('"type" "%s" ', [msg.ContentSubType]);
end;
result := Trim(Result) + Format(' %s (%s"boundary" "%s") NIL NIL',
[subType, cntType, msg.Boundary]);
end;
end;
result := 'BODYSTRUCTURE (' + result + ')';
buf := TclTranslator.GetBytes(result);
AResponse.Write(buf[0], Length(buf));
finally
msg.Free();
end;
end;
class procedure TclImap4FetchBodyStructure.ExtractContentTypeParts(
const AContentType: string; var AType, ASubType: string);
var
words: TStrings;
begin
AType := 'NIL';
ASubType := 'NIL';
words := TStringList.Create();
try
ExtractQuotedWords(AContentType, words, '/');
if (words.Count > 0) then
begin
AType := '"' + words[0] + '"';
end;
if (words.Count > 1) then
begin
ASubType := '"' + words[1] + '"';
end;
finally
words.Free();
end;
end;
class function TclImap4FetchBodyStructure.GetMimeBodySize(ABody: TclMessageBody): string;
var
cntType, subType: string;
begin
ExtractContentTypeParts(ABody.ContentType, cntType, subType);
if SameText(cntType, '"text"') then
begin
Result := Format('%d %d ', [ABody.EncodedSize, ABody.EncodedLines]);
end else
begin
Result := Format('%d ', [ABody.EncodedSize]);
end;
end;
class function TclImap4FetchBodyStructure.GetMimeBodyStructure(ABodies: TclMessageBodies): string;
var
i: Integer;
body: TclMessageBody;
s, cntType, subType: string;
begin
Result := '';
for i := 0 to ABodies.Count - 1 do
begin
body := ABodies[i];
if (ABodies.Count > 1) then
begin
Result := Result + '(';
end;
if (body is TclTextBody) then
begin
ExtractContentTypeParts(body.ContentType, cntType, subType);
Result := Result + Format('%s %s ', [cntType, subType]);
if (TclTextBody(body).CharSet <> '') then
begin
Result := Result + Format('("charset" "%s") ', [TclTextBody(body).CharSet]);
end;
Result := Result + 'NIL NIL ' + EncodingMap[body.Encoding] + ' ';
Result := Result + GetMimeBodySize(body);
Result := Result + 'NIL NIL NIL';
end else
if (body is TclAttachmentBody) then
begin
ExtractContentTypeParts(body.ContentType, cntType, subType);
Result := Result + Format('%s %s ', [cntType, subType]);
Result := Result + Format('("name" "%s") ', [TclAttachmentBody(body).FileName]);
s := TclAttachmentBody(body).ContentID;
if (s <> '') then
begin
if (s[1] <> '<') then
begin
s := '<' + s + '>';
end;
Result := Result + '"' + s + '" NIL ';
Result := Result + EncodingMap[body.Encoding] + ' ';
Result := Result + GetMimeBodySize(body);
Result := Result + 'NIL NIL NIL';
end else
begin
Result := Result + 'NIL NIL '+ EncodingMap[body.Encoding] + ' ';
Result := Result + GetMimeBodySize(body);
Result := Result + Format('NIL ("attachment" ("filename" "%s")) NIL', [TclAttachmentBody(body).FileName]);
end;
end else
if (body is TclMultipartBody) then
begin
Result := Result + GetMimeBodyStructure(TclMultipartBody(body).Bodies);
ExtractContentTypeParts(body.ContentType, cntType, subType);
cntType := '';
if (TclMultipartBody(body).ContentSubType <> '') then
begin
cntType := Format('"type" "%s" ', [TclMultipartBody(body).ContentSubType]);
end;
Result := Trim(Result) + Format(' %s (%s"boundary" "%s") NIL NIL',
[subType, cntType, TclMultipartBody(body).Boundary]);
end;
if (ABodies.Count > 1) then
begin
Result := Result + ')';
end;
end;
end;
class procedure TclImap4FetchBodyStructure.GetUueBodySize(AMessage: TStrings;
var ASize, ALines: Integer);
var
i: Integer;
isBody: Boolean;
begin
ASize := 0;
ALines := 0;
isBody := False;
for i := 0 to AMessage.Count - 1 do
begin
if isBody then
begin
ASize := ASize + Length(AMessage[i]) + Length(#13#10);
end else
if (AMessage[i] = '') then
begin
isBody := True;
ALines := i;
end;
end;
if (ALines > 0) then
begin
ALines := AMessage.Count - ALines - 1;
end;
end;
{ TclImap4FetchBody }
class procedure TclImap4FetchBody.Build(AMessage: TStrings; const ACommand,
ABodyPart: string; AResponse: TStream);
var
msg: TclMailMessage;
bodyPart: TStrings;
begin
if (ABodyPart = '') then
begin
BuildBodyPartTitle(ACommand, GetStringsSize(AMessage), AResponse);
TclStringsUtils.SaveStrings(AMessage, AResponse, '');
end else
begin
msg := nil;
bodyPart := nil;
try
msg := TclMailMessage.Create(nil);
bodyPart := TStringList.Create();
msg.MessageSource := AMessage;
ExtractQuotedWords(UpperCase(ABodyPart), bodyPart, '.');
BuildBodyPart(AMessage, msg.Bodies, nil, ACommand, bodyPart, AResponse);
finally
bodyPart.Free();
msg.Free();
end;
end;
end;
class procedure TclImap4FetchBody.BuildBodyContent(AMessage: TStrings;
ABody: TclMessageBody; const ACommand: string; AResponse: TStream;
AReturnHeader: Boolean);
var
i, ind, len,
start, lines, size: Integer;
buf: TclByteArray;
begin
{$IFNDEF DELPHI2005}buf := nil;{$ENDIF}
if (ABody <> nil) then
begin
if AReturnHeader then
begin
start := ABody.RawStart;
end else
begin
start := ABody.EncodedStart;
end;
lines := ABody.EncodedLines;
size := ABody.EncodedSize;
end else
begin
start := 0;
lines := AMessage.Count;
size := GetStringsSize(AMessage);
end;
if AReturnHeader then
begin
size := 0;
for i := 0 to lines - 1 do
begin
ind := i + start;
if (ind >= AMessage.Count) then
begin
lines := i + 1;
Break;
end;
len := Length(AMessage[ind]);
size := size + len + 2;
if (len = 0) then
begin
lines := i + 1;
Break;
end;
end;
end;
BuildBodyPartTitle(ACommand, size, AResponse);
for i := 0 to lines - 1 do
begin
ind := i + start;
if (ind >= AMessage.Count) then
begin
Break;
end;
buf := TclTranslator.GetBytes(AMessage[ind]);
if (Length(buf) > 0) then
begin
AResponse.Write(buf[0], Length(buf));
end;
buf := TclTranslator.GetBytes(#13#10);
AResponse.Write(buf[0], Length(buf));
end;
end;
class procedure TclImap4FetchBody.BuildBodyFields(AMessage: TStrings;
ABody: TclMessageBody; const ACommand, AFetchFields: string;
AResponse: TStream; isNot: Boolean);
var
i, ind: Integer;
fetchParams, reqFields,
src: TStrings;
fieldList: TclMailHeaderFieldList;
result: string;
buf: TclByteArray;
begin
{$IFNDEF DELPHI2005}buf := nil;{$ENDIF}
result := '';
fetchParams := nil;
reqFields := nil;
fieldList := nil;
try
fetchParams := TStringList.Create();
reqFields := TStringList.Create();
ExtractQuotedWords(AFetchFields, fetchParams, ' ', ['('], [')'], False);
if ((fetchParams.Count = 2) and (Length(fetchParams[0]) <> 0) and (Length(fetchParams[1]) <> 0)) then
begin
ExtractQuotedWords(fetchParams[1], reqFields, ' ', ['"'], ['"'], False);
fieldList := TclMailHeaderFieldList.Create(DefaultCharSet, cmNone, DefaultCharsPerLine);
src := AMessage;
if (ABody <> nil) then
begin
src := ABody.RawHeader;
end;
fieldList.Parse(0, src);
if (isNot) then
begin
for i := 0 to fieldList.FieldList.Count - 1 do
begin
if (FindInStrings(reqFields, fieldList.FieldList[i]) < 0) then
begin
result := result + fieldList.GetFieldName(i) + ': '+ fieldList.GetFieldValue(i) + #13#10;
end;
end;
end else
begin
for i := 0 to reqFields.Count - 1 do
begin
ind := FindInStrings(fieldList.FieldList, reqFields[i]);
if (ind > -1) then
begin
result := result + fieldList.GetFieldName(ind) + ': '+ fieldList.GetFieldValue(ind) + #13#10;
end;
end;
end;
if (result <> '') then
begin
result := result + #13#10;
end;
end;
finally
fieldList.Free();
reqFields.Free();
fetchParams.Free();
end;
if (result = '') then
begin
result := ACommand + ' NIL';
buf := TclTranslator.GetBytes(result);
AResponse.Write(buf[0], Length(buf));
end else
begin
buf := TclTranslator.GetBytes(result);
BuildBodyPartTitle(ACommand, Length(buf), AResponse);
AResponse.Write(buf[0], Length(buf));
end;
end;
class procedure TclImap4FetchBody.BuildBodyPart(AMessage: TStrings;
ABodies: TclMessageBodies; AParent: TclMessageBody; const ACommand: string;
ABodyPart: TStrings; AResponse: TStream);
var
part: Integer;
body: TclMessageBody;
begin
if (ABodyPart.Count = 0) then Exit;
part := StrToIntDef(ABodyPart[0], -1);
if (part > 0) then
begin
part := part - 1;
if ((ABodies <> nil) and (part > -1) and (part < ABodies.Count)) then
begin
body := ABodies[part];
if (ABodyPart.Count > 1) then
begin
ABodyPart.Delete(0);
if (body is TclMultipartBody) then
begin
BuildBodyPart(AMessage, TclMultipartBody(body).Bodies, body, ACommand, ABodyPart, AResponse);
end else
begin
BuildBodyPart(AMessage, nil, body, ACommand, ABodyPart, AResponse);
end;
end else
begin
BuildBodyContent(AMessage, body, ACommand, AResponse, False);
end;
end else
begin
BuildBodyContent(AMessage, AParent, ACommand, AResponse, False);
end;
end else
begin
if (ABodyPart[0] = 'HEADER') then
begin
if ((ABodyPart.Count > 1) and (Pos('FIELDS', ABodyPart[1]) > 0)) then
begin
if ((ABodyPart.Count > 2) and (Pos('NOT', ABodyPart[2]) > 0)) then
begin
BuildBodyFields(AMessage, AParent, ACommand, ABodyPart[2], AResponse, True);
end else
begin
BuildBodyFields(AMessage, AParent, ACommand, ABodyPart[1], AResponse, False);
end;
end else
begin
BuildBodyContent(AMessage, AParent, ACommand, AResponse, True);
end;
end else
if (ABodyPart[0] = 'MIME') then
begin
BuildBodyContent(AMessage, AParent, ACommand, AResponse, True);
end else
if (ABodyPart[0] = 'TEXT') then
begin
if (ABodies <> nil) then
begin
if (not BuildTextBody(AMessage, ABodies, ACommand, AResponse)) then
begin
BuildBodyContent(AMessage, AParent, ACommand, AResponse, False);
end;
end else
begin
BuildBodyContent(AMessage, AParent, ACommand, AResponse, False);
end;
end;
end;
end;
class procedure TclImap4FetchBody.BuildBodyPartTitle(const ACommand: string;
ADataSize: Integer; AResponse: TStream);
var
buf: TclByteArray;
begin
buf := TclTranslator.GetBytes(ACommand + ' {' + IntToStr(ADataSize) + '}'#13#10);
AResponse.Write(buf[0], Length(buf));
end;
class function TclImap4FetchBody.BuildTextBody(AMessage: TStrings;
ABodies: TclMessageBodies; const ACommand: string;
AResponse: TStream): Boolean;
var
i: Integer;
begin
for i := 0 to ABodies.Count - 1 do
begin
if (ABodies[i] is TclMultipartBody) then
begin
if BuildTextBody(AMessage, TclMultipartBody(ABodies[i]).Bodies, ACommand, AResponse) then
begin
Result := True;
Exit;
end;
end else
if (ABodies[i] is TclTextBody) then
begin
BuildBodyContent(AMessage, ABodies[i], ACommand, AResponse, False);
Result := True;
Exit;
end;
end;
Result := False;
end;
{ TclImap4FetchItem }
constructor TclImap4FetchItem.Create(const AName: string);
begin
inherited Create();
FName := AName;
FPartial := '';
FSection := '';
end;
{ TclImap4FetchList }
procedure TclImap4FetchList.Add(AItem: TclImap4FetchItem);
begin
FList.Add(AItem);
end;
procedure TclImap4FetchList.Clear;
begin
FList.Clear();
end;
constructor TclImap4FetchList.Create;
begin
inherited Create();
FList := TObjectList.Create(True);
end;
procedure TclImap4FetchList.Delete(Index: Integer);
begin
FList.Delete(Index);
end;
destructor TclImap4FetchList.Destroy;
begin
FList.Free();
inherited Destroy();
end;
function TclImap4FetchList.GetCount: Integer;
begin
Result := FList.Count;
end;
function TclImap4FetchList.GetItem(Index: Integer): TclImap4FetchItem;
begin
Result := TclImap4FetchItem(FList[Index]);
end;
procedure TclImap4FetchList.Parse(const ASource: string);
begin
Clear();
ParseDataItems(ASource);
ParseBodyStructure();
ParseMacros();
end;
procedure TclImap4FetchList.ParseBodyStructure;
var
i: Integer;
item: TclImap4FetchItem;
begin
for i := 0 to Count - 1 do
begin
item := Items[i];
if (item.Name = 'BODY') then
begin
if (item.Section = '') then
begin
item.Name := 'BODYSTRUCTURE';
end else
begin
item.Section := ExtractQuotedString(item.Section, '[', ']');
end;
end else
if (item.Name = 'BODY.PEEK') then
begin
item.Section := ExtractQuotedString(item.Section, '[', ']');
end;
end;
end;
procedure TclImap4FetchList.ParseDataItems(const ASource: string);
var
len, next: Integer;
inParams, inPartial: Boolean;
item: TclImap4FetchItem;
curText: string;
begin
if (ASource = '') then Exit;
len := Length(ASource);
if (len = 0) then Exit;
next := 1;
inParams := False;
inPartial := False;
item := nil;
curText := '';
while (len > 0) do
begin
case ASource[next] of
'<':
begin
if (inParams) then
begin
curText := curText + ASource[next];
end;
inParams := True;
inPartial := True;
end;
'>':
begin
if (inPartial) then
begin
if (item <> nil) then
begin
item.Partial := curText;
end;
curText := '';
inParams := False;
end else
if (inParams) then
begin
curText := curText + ASource[next];
end;
inPartial := False;
end;
' ':
begin
if (inParams) then
begin
curText := curText + ASource[next];
end else
begin
item := nil;
if (curText <> '') then
begin
item := TclImap4FetchItem.Create(UpperCase(curText));
Add(item);
end;
curText := '';
end;
end;
'[':
begin
inParams := True;
item := nil;
if (curText <> '') then
begin
item := TclImap4FetchItem.Create(UpperCase(curText));
Add(item);
end;
curText := ASource[next];
end;
']':
begin
curText := curText + ASource[next];
if (inParams and (item <> nil) and (curText <> '')) then
begin
item.Section := curText;
end;
curText := '';
inParams := False;
end
else
begin
curText := curText + ASource[next];
end;
end;
Inc(next);
Dec(len);
end;
if (not inParams and (curText <> '')) then
begin
item := TclImap4FetchItem.Create(UpperCase(curText));
Add(item);
end;
end;
procedure TclImap4FetchList.ParseMacros;
var
i: Integer;
item: TclImap4FetchItem;
begin
for i := Count - 1 downto 0 do
begin
item := Items[i];
if (item.Name = 'ALL') then
begin
Delete(i);
Add(TclImap4FetchItem.Create('FLAGS'));
Add(TclImap4FetchItem.Create('INTERNALDATE'));
Add(TclImap4FetchItem.Create('RFC822.SIZE'));
Add(TclImap4FetchItem.Create('ENVELOPE'));
end else
if (item.Name = 'FAST') then
begin
Delete(i);
Add(TclImap4FetchItem.Create('FLAGS'));
Add(TclImap4FetchItem.Create('INTERNALDATE'));
Add(TclImap4FetchItem.Create('RFC822.SIZE'));
end else
if (item.Name = 'FULL') then
begin
Delete(i);
Add(TclImap4FetchItem.Create('FLAGS'));
Add(TclImap4FetchItem.Create('INTERNALDATE'));
Add(TclImap4FetchItem.Create('RFC822.SIZE'));
Add(TclImap4FetchItem.Create('ENVELOPE'));
Add(TclImap4FetchItem.Create('BODY'));
end;
end;
end;
end.
|
unit Mat.Components;
interface
uses System.SysUtils, System.JSON, System.IOUtils, WinApi.Windows, Dialogs, FireDAC.Stan.Param;
type
TComponentParser = class
private
FTitle: string;
FPackage: string;
FVendor: string;
FProjectHomeUrl: string;
FLicenseName: string;
FLicenseType: string;
FClasses: string;
FPlatformsSupport: string;
FRADStudioVersionsSupport: string;
FVersionsCompatibility: string;
FAnalogues: string;
FConvertTo: string;
FComment: string;
public
procedure ParseFields(UnitName: string);
procedure JSONToSQL;
property Title: string read FTitle write FTitle;
property Package: string read FPackage write FPackage;
property Vendor: string read FVendor write FVendor;
property ProjectHomeUrl: string read FProjectHomeUrl
write FProjectHomeUrl;
property LicenseName: string read FLicenseName write FLicenseName;
property LicenseType: string read FLicenseType write FLicenseType;
property Classes: string read FClasses write FClasses;
property PlatformsSupport: string read FPlatformsSupport
write FPlatformsSupport;
property RADStudioVersionsSupport: string read FRADStudioVersionsSupport
write FRADStudioVersionsSupport;
property VersionsCompatibility: string read FVersionsCompatibility
write FVersionsCompatibility;
property Analogues: string read FAnalogues write FAnalogues;
property Comment: string read FComment write FComment;
property ConvertTo: string read FConvertTo write FConvertTo;
end;
var
FComponentParser: TComponentParser;
implementation
uses Mat.Constants, Mat.AnalysisProcessor;
procedure TComponentParser.JSONToSQL;
var
JsonString: string;
LFilename: string;
JSONEnum: TJSONObject.TEnumerator;
Tempjson: TJSONObject;
i: integer;
begin
LFilename := (ExtractFilePath(ParamStr(0)) + DATABASE_FOLDER +
JSON_FILE_NAME);
if FileExists(LFilename) then
begin
JsonString := TFile.ReadAllText(LFilename);
Tempjson := TJSONObject.ParseJSONValue
(TEncoding.UTF8.GetBytes(JsonString), 0) as TJSONObject;
end
else
begin
Tempjson := nil;
FileClose(FileCreate(LFilename));
end;
JSONEnum := Tempjson.GetEnumerator;
if Tempjson <> nil then
begin
for i := 0 to Tempjson.Count - 1 do
begin
JSONEnum.MoveNext;
Tempjson := TJSONObject.ParseJSONValue
(TEncoding.UTF8.GetBytes(JSONEnum.Current.JsonValue.ToString), 0)
as TJSONObject;
with Tempjson do
begin
FTitle := JSONEnum.Current.JsonString.ToString;
FTitle := StringReplace(FTitle, '"', '', [rfReplaceAll]);
TryGetValue(PACKAGE_JSON_PAIR, FPackage);
TryGetValue(VENDOR_JSON_PAIR, FVendor);
TryGetValue(PROJECTHOMEURL_JSON_PAIR, FProjectHomeUrl);
TryGetValue(LICENSENAME_JSON_PAIR, FLicenseName);
TryGetValue(LICENSETYPE_JSON_PAIR, FLicenseType);
TryGetValue(CLASSES_JSON_PAIR, FClasses);
TryGetValue(PLATFORMSSUPPORT_JSON_PAIR, FPlatformsSupport);
TryGetValue(RADSTUDIOVERSIONSSUPPORT_JSON_PAIR,
FRADStudioVersionsSupport);
TryGetValue(VERSIONSCOMPATIBILITY_JSON_PAIR, FVersionsCompatibility);
TryGetValue(ANALOGUES_JSON_PAIR, FAnalogues);
TryGetValue(COMMENT_JSON_PAIR, FComment);
TryGetValue(CONVERTTO_JSON_PAIR, FConvertTo);
end;
FAnalysisProcessor.InsertToTable(COMPONENTS_DATABASE_TABLE_NAME);
end;
end
else
showmessage(COMPONENTS_DATABASE_MISSING_ERR);
end;
procedure TComponentParser.ParseFields(UnitName: string);
begin
if not UnitName.IsEmpty then
begin
FAnalysisProcessor.stFDQuery_Update.Sql.Text :=
(COMPONENTS_PARSE_FIELDS_SELECT_SQL +
UnitName.ToLower + '''');
FAnalysisProcessor.stFDQuery_Update.Open;
if FAnalysisProcessor.stFDQuery_Update.RecordCount > 0 then
begin
FAnalysisProcessor.stFDQuery_Update.Sql.Text :=
(COMPONENTS_PARSE_FIELDS_INSERT_SQL +
UnitName.ToLower + '''');
FAnalysisProcessor.stFDQuery_Update.ExecSQL;
end
else
begin
FAnalysisProcessor.stFDQuery_Update.Sql.Text :=
(INSERT_USES_SQL);
FAnalysisProcessor.stFDQuery_Update.Params.ParamByName(FTITLE_FIELD_NAME)
.Value := UnitName;
FAnalysisProcessor.stFDQuery_Update.Params.ParamByName
(FLOWER_TITLE_FIELD_NAME).Value := UnitName.ToLower;
FAnalysisProcessor.stFDQuery_Update.ExecSQL;
end;
end;
end;
initialization
FComponentParser := TComponentParser.Create;
end.
|
unit TaskForma;
{$I defines.inc}
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, GridForma, DBGridEhGrouping,
ToolCtrlsEh, DBGridEhToolCtrls, DynVarsEh, CnErrorProvider, Vcl.Menus,
System.Actions, Vcl.ActnList, Data.DB, Vcl.StdCtrls, Vcl.Buttons,
Vcl.ExtCtrls, Vcl.ComCtrls, Vcl.ToolWin, EhLibVCL, GridsEh,
DBAxisGridsEh, DBGridEh, FIBDatabase, pFIBDatabase, FIBDataSet,
pFIBDataSet, DBCtrlsEh, Vcl.Mask, MemTableDataEh, MemTableEh, System.UITypes;
type
TTaskForm = class(TGridForm)
dsTask: TpFIBDataSet;
trRead: TpFIBTransaction;
trWrite: TpFIBTransaction;
pgcMSG: TPageControl;
tsGrid: TTabSheet;
tsEdit: TTabSheet;
dbgMsg: TDBGridEh;
dsMSG: TpFIBDataSet;
srcMSG: TDataSource;
pnlButtons: TPanel;
btnDel1: TSpeedButton;
btnAdd1: TSpeedButton;
btnEdit1: TSpeedButton;
dlgColor: TColorDialog;
edtTITLE: TDBEditEh;
mmoNOTICE: TDBMemoEh;
edtPLAN_DATE: TDBDateTimeEditEh;
edtEXEC_DATE: TDBDateTimeEditEh;
btnColor: TButton;
lbl1: TLabel;
lbl2: TLabel;
lbl3: TLabel;
Label1: TLabel;
btnClearColor: TButton;
mmoTEXT: TDBMemoEh;
cbbOBJ_TYPE: TDBComboBoxEh;
edtOBJ_ID: TDBEditEh;
btnGoObject: TSpeedButton;
dbgUsers: TDBGridEh;
dsUsers: TpFIBDataSet;
srcUsers: TDataSource;
mtbUsers: TMemTableEh;
actRefresh: TAction;
btnRefresh: TToolButton;
dsFilter: TMemTableEh;
actFilter: TAction;
btnFilter: TToolButton;
actDelMessage: TAction;
btn1: TToolButton;
btn2: TToolButton;
btnOpenAll: TSpeedButton;
btnOk: TBitBtn;
btnMsgCncl: TBitBtn;
actMsgSave: TAction;
actMsgCancel: TAction;
actClose: TAction;
btnClose: TToolButton;
btnSPclose: TToolButton;
pmOpenObjects: TPopupMenu;
actOpenCustAddr: TAction;
miOpenCustAddr: TMenuItem;
procedure dbGridRowDetailPanelShow(Sender: TCustomDBGridEh; var CanShow: Boolean);
procedure dbGridRowDetailPanelHide(Sender: TCustomDBGridEh; var CanHide: Boolean);
procedure FormShow(Sender: TObject);
procedure actNewExecute(Sender: TObject);
procedure btnColorClick(Sender: TObject);
procedure btnClearColorClick(Sender: TObject);
procedure actEditExecute(Sender: TObject);
procedure btnSaveLinkClick(Sender: TObject);
procedure actDeleteExecute(Sender: TObject);
procedure btnEdit1Click(Sender: TObject);
procedure btnAdd1Click(Sender: TObject);
procedure btnGoObjectClick(Sender: TObject);
procedure dbgMsgDblClick(Sender: TObject);
procedure dbGridGetCellParams(Sender: TObject; Column: TColumnEh; AFont: TFont; var Background: TColor;
State: TGridDrawState);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure dsTaskNewRecord(DataSet: TDataSet);
procedure dbgMsgColumns1CellDataLinkClick(Grid: TCustomDBGridEh; Column: TColumnEh);
procedure actRefreshExecute(Sender: TObject);
procedure actFilterExecute(Sender: TObject);
procedure dsFilterNewRecord(DataSet: TDataSet);
procedure actDelMessageExecute(Sender: TObject);
procedure btn1Click(Sender: TObject);
procedure btnOpenAllClick(Sender: TObject);
procedure actMsgCancelExecute(Sender: TObject);
procedure actMsgSaveExecute(Sender: TObject);
procedure dbgUsersKeyPress(Sender: TObject; var Key: Char);
procedure actCloseExecute(Sender: TObject);
procedure srcDataSourceDataChange(Sender: TObject; Field: TField);
procedure actOpenCustAddrExecute(Sender: TObject);
private
FclOverdue: TColor;
FclSoon: TColor;
FCanClose: Boolean;
procedure EditMSG();
procedure DeleteMSG();
procedure EditTask();
procedure NewTask();
procedure NewMSG();
procedure CancelEditMsg();
procedure SaveUsers;
procedure GetUsers;
procedure SetUsers(const new: Boolean = False);
procedure GoObject;
procedure GoObjects;
function GenerateFilter: string;
procedure SetDefaultFilter;
procedure CloseSelectedAsCurrent;
public
procedure FindId(const Value: integer);
end;
var
TaskForm: TTaskForm;
procedure FindTask(const Value: integer);
implementation
{$R *.dfm}
uses PrjConst, DM, pFIBQuery, MAIN, TaskFilterForma, AtrCommon, SelDateForma;
procedure FindTask(const Value: integer);
begin
if Not Assigned(TaskForm) then
TaskForm := TTaskForm.Create(Application);
TaskForm.Show;
TaskForm.FindId(Value);
end;
procedure TTaskForm.actCloseExecute(Sender: TObject);
var
cd: TDate;
fq: TpFIBQuery;
id: integer;
begin
inherited;
if (dsTask.RecordCount = 0) or (dsTask.FieldByNAme('ID').IsNull) then
Exit;
cd := Now();
if SelectDate(cd, rsCloseTask) then
begin
id := dsTask['ID'];
fq := TpFIBQuery.Create(Self);
try
fq.Database := dmMain.dbTV;
fq.Transaction := dmMain.trWriteQ;
fq.sql.Text := 'UPDATE TASKLIST SET EXEC_DATE = :EXEC_DATE WHERE ID = :OLD_ID';
fq.ParamByName('OLD_ID').AsInteger := id;
fq.ParamByName('EXEC_DATE').AsDate := cd;
fq.Transaction.StartTransaction;
fq.ExecQuery;
fq.Transaction.Commit;
fq.Close;
finally
fq.Free;
end;
dsTask.DisableControls;
dsTask.CloseOpen(true);
dsTask.Locate('ID', id, []);
dsTask.EnableControls;
end;
end;
procedure TTaskForm.actDeleteExecute(Sender: TObject);
begin
inherited;
if srcDataSource.DataSet.RecordCount = 0 then
Exit;
if srcDataSource.DataSet['ADDED_BY'] = dmMain.User then
if (MessageDlg(Format(rsDeleteWithName, [srcDataSource.DataSet['TITLE']]), mtConfirmation, [mbYes, mbNo], 0) = mrYes)
then
srcDataSource.DataSet.Delete;
end;
procedure TTaskForm.actDelMessageExecute(Sender: TObject);
begin
inherited;
DeleteMSG();
end;
procedure TTaskForm.actEditExecute(Sender: TObject);
begin
inherited;
if ((ActiveControl.Name = 'dbgMsg') or (dsMSG.DataSource.State in [dsEdit, dsInsert])) then
EditMSG()
else
EditTask();
end;
procedure TTaskForm.actFilterExecute(Sender: TObject);
var
cr: TCursor;
begin
TaskFilterForm := TTaskFilterForm.Create(Application);
cr := Screen.Cursor;
try
if not dsFilter.Active then
SetDefaultFilter;
if dsFilter.RecordCount = 0 then
begin
dsFilter.Insert;
end;
if TaskFilterForm.ShowModal = mrOk then
begin
Screen.Cursor := crHourGlass;
dsTask.Close;
dsTask.ParamByName('Filter').Value := GenerateFilter;
dsTask.Open;
end;
finally
TaskFilterForm.Free;
TaskFilterForm := nil;
Screen.Cursor := cr;
end;
end;
procedure TTaskForm.actMsgCancelExecute(Sender: TObject);
begin
inherited;
CancelEditMsg();
end;
procedure TTaskForm.actMsgSaveExecute(Sender: TObject);
begin
inherited;
if dsMSG.State in [dsEdit, dsInsert] then
dsMSG.Post;
pgcMSG.ActivePage := tsGrid;
dsTask.Refresh;
dbgMsg.SetFocus;
end;
procedure TTaskForm.actNewExecute(Sender: TObject);
begin
inherited;
if not Assigned(ActiveControl) then
NewTask()
else
begin
if (ActiveControl.Name = 'dbgMsg') then
NewMSG()
else
NewTask();
end;
end;
procedure TTaskForm.actOpenCustAddrExecute(Sender: TObject);
var
ObjList: TStringList;
s: string;
fq : TpFIBQuery;
begin
inherited;
if (dsTask.RecordCount = 0) or (dsMSG.RecordCount = 0) then
Exit;
dsMSG.DisableControls;
dsMSG.First;
ObjList := TStringList.Create;
try
ObjList.Sorted := true;
ObjList.Duplicates := dupIgnore;
fq := TpFIBQuery.Create(Self);
try
fq.Database := dmMain.dbTV;
fq.Transaction := dmMain.trReadQ;
fq.sql.Text := 'select Cust_Code from customer where Account_No = :Obj_Id';
while not dsMSG.Eof do
begin
if (not dsMSG.FieldByNAme('OBJ_TYPE').IsNull) and (dsMSG['OBJ_TYPE'] = 'A') and
(not dsMSG.FieldByNAme('OBJ_ID').IsNull) then
begin
fq.ParamByName('OBJ_ID').AsString := dsMSG['OBJ_ID'];
fq.Transaction.StartTransaction;
fq.ExecQuery;
if not fq.FN('Cust_Code').IsNull then
ObjList.Add(fq.FN('Cust_Code').AsString);
fq.Transaction.Commit;
fq.Close;
end;
dsMSG.Next;
end;
finally
fq.Free;
end;
if (ObjList.Count > 0) then
s := ObjList.CommaText
else
s := '';
finally
FreeAndNil(ObjList);
end;
dsMSG.First;
dsMSG.EnableControls;
if (s <> '') then
A4MainForm.SearchFromTask('ALL_CUST_ADDR', s);
end;
procedure TTaskForm.actRefreshExecute(Sender: TObject);
var
i: integer;
begin
inherited;
if dsTask.RecordCount > 0 then
i := dsTask['ID']
else
i := -1;
dsTask.CloseOpen(true);
if i > 0 then
dsTask.Locate('ID', i, []);
end;
procedure TTaskForm.btn1Click(Sender: TObject);
begin
inherited;
A4MainForm.ClearAlert();
end;
procedure TTaskForm.btnAdd1Click(Sender: TObject);
begin
inherited;
NewMSG();
end;
procedure TTaskForm.btnClearColorClick(Sender: TObject);
begin
inherited;
dsTask.FieldByNAme('COLOR').Clear;
pnlEdit.COLOR := clBtnFace;
end;
procedure TTaskForm.btnColorClick(Sender: TObject);
begin
inherited;
if dlgColor.Execute then
begin
dsTask['COLOR'] := ColorToString(dlgColor.COLOR);
pnlEdit.COLOR := dlgColor.COLOR;
end;
end;
procedure TTaskForm.btnEdit1Click(Sender: TObject);
begin
inherited;
EditMSG();
end;
procedure TTaskForm.btnGoObjectClick(Sender: TObject);
begin
inherited;
GoObject;
end;
procedure TTaskForm.btnOpenAllClick(Sender: TObject);
begin
inherited;
GoObjects;
end;
procedure TTaskForm.btnSaveLinkClick(Sender: TObject);
var
errors: Boolean;
begin
errors := False;
if (edtTITLE.Text = '') then
begin
errors := true;
CnErrors.SetError(edtTITLE, rsEmptyFieldError, iaMiddleLeft, bsNeverBlink);
end
else
CnErrors.Dispose(edtTITLE);
if not errors then
begin
inherited;
SaveUsers;
if (dbGrid.SelectedRows.Count > 0) then
CloseSelectedAsCurrent
else
dsTask.Refresh;
end;
end;
procedure TTaskForm.dbgMsgColumns1CellDataLinkClick(Grid: TCustomDBGridEh; Column: TColumnEh);
begin
inherited;
GoObject;
end;
procedure TTaskForm.dbgMsgDblClick(Sender: TObject);
begin
inherited;
if (dsMSG.FieldByNAme('ID').IsNull) then
NewMSG
else
EditMSG;
end;
procedure TTaskForm.dbGridGetCellParams(Sender: TObject; Column: TColumnEh; AFont: TFont; var Background: TColor;
State: TGridDrawState);
var
bgColor: TColor;
s: string;
begin
inherited;
if not dsTask.FieldByNAme('COLOR').IsNull then
begin
s := dsTask.FieldByNAme('COLOR').Value;
if s <> '' then
begin
bgColor := StringToColor(s);
Background := bgColor;
end;
end;
if (not dsTask.FieldByNAme('EXEC_DATE').IsNull) and (dsTask['EXEC_DATE'] < Now()) then
AFont.Style := AFont.Style + [fsStrikeOut]
else
begin
AFont.Style := AFont.Style - [fsStrikeOut];
if ((not dsTask.FieldByNAme('PLAN_DATE').IsNull) and (dsTask.FieldByNAme('EXEC_DATE').IsNull)) then
begin
if (dsTask.FieldByNAme('PLAN_DATE').AsDateTime < Now()) then
Background := FclOverdue
else if (dsTask.FieldByNAme('PLAN_DATE').AsDateTime > Date()) then
Background := FclSoon
end;
end;
end;
procedure TTaskForm.dbGridRowDetailPanelHide(Sender: TCustomDBGridEh; var CanHide: Boolean);
begin
inherited;
CanHide := (pgcMSG.ActivePage <> tsEdit);
if CanHide then
dsMSG.Close;
end;
procedure TTaskForm.dbGridRowDetailPanelShow(Sender: TCustomDBGridEh; var CanShow: Boolean);
begin
inherited;
if dsMSG.Active then
dsMSG.Close;
if (dmMain.GetSettingsValue('SHOW_AS_BALANCE') = '1') then
dsMSG.ParamByName('sab').AsInteger := 1
else
dsMSG.ParamByName('sab').AsInteger := 0;
dsMSG.Open;
end;
procedure TTaskForm.dbgUsersKeyPress(Sender: TObject; var Key: Char);
begin
inherited;
if (Ord(Key) = VK_SPACE) or (Ord(Key) = VK_RETURN) then
begin
if mtbUsers.RecordCount > 0 then
begin
mtbUsers.Edit;
if mtbUsers.FieldByNAme('IN_TASK').IsNull then
mtbUsers['IN_TASK'] := true
else
mtbUsers['IN_TASK'] := not mtbUsers['IN_TASK'];
mtbUsers.Post;
end;
end;
end;
procedure TTaskForm.dsFilterNewRecord(DataSet: TDataSet);
begin
inherited;
DataSet['NotClosed'] := False;
DataSet['INVERSION'] := False;
DataSet['ALLUSERS'] := False;
end;
procedure TTaskForm.dsTaskNewRecord(DataSet: TDataSet);
begin
inherited;
dsTask['added_by'] := dmMain.User;
end;
procedure TTaskForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
inherited;
if dsMSG.Active then
dsMSG.Close;
if dsTask.Active then
dsTask.Close;
if mtbUsers.Active then
mtbUsers.Close;
TaskForm := nil;
end;
procedure TTaskForm.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if (Ord(Key) = VK_ESCAPE) and (dbGrid.RowDetailPanel.Visible) then
begin
if pgcMSG.ActivePage = tsEdit then
actMsgCancel.Execute
else
begin
dbGrid.RowDetailPanel.Visible := False;
dbGrid.SetFocus;
end;
end
else if (ssCtrl In Shift) And (Ord(Key) = VK_RETURN) and (dbGrid.RowDetailPanel.Visible) then
begin
if pgcMSG.ActivePage = tsEdit then
actMsgSave.Execute;
end
else if (Self.ActiveControl = dbGrid) then
begin
if (Ord(Key) = VK_RETURN) then
dbGrid.RowDetailPanel.Visible := not dbGrid.RowDetailPanel.Visible
end;
inherited;
end;
procedure TTaskForm.FormShow(Sender: TObject);
var
i: integer;
s: String;
begin
inherited;
if dsTask.Active then
dsTask.Close;
s := GetGridSortOrder(dbGrid);
dsTask.OrderClause := s;
SetDefaultFilter;
dsTask.Open;
s := GetGridSortOrder(dbgMsg);
if dsMSG.Active then
dsMSG.Close;
dsMSG.OrderClause := s;
for i := 0 to pgcMSG.PageCount - 1 do
pgcMSG.Pages[i].TabVisible := False;
pgcMSG.ActivePageIndex := 0;
try
FclOverdue := StringToColor(dmMain.GetSettingsValue('COLOR_DOLG'));
except
FclOverdue := clRed;
end;
try
FclSoon := StringToColor(dmMain.GetSettingsValue('COLOR_OFFMONEY'));
except
FclSoon := clBlue;
end;
FCanClose := dmMain.AllowedAction(rght_Task_Close);
btnSPclose.Visible := FCanClose;
actClose.Visible := FCanClose;
GetUsers;
end;
procedure TTaskForm.EditMSG();
begin
if (dsTask.RecordCount = 0) or (dsMSG.RecordCount = 0) then
Exit;
if (dsTask.FieldByNAme('ID').IsNull) or (dsMSG.FieldByNAme('ID').IsNull) then
Exit;
if dmMain.User <> dsMSG['Added_By'] then
Exit;
pgcMSG.ActivePage := tsEdit;
if (not(dsMSG.State in [dsEdit, dsInsert])) then
dsMSG.Edit;
mmoTEXT.SetFocus;
end;
procedure TTaskForm.NewTask();
begin
FCanEdit := true;
SetUsers(true);
StartEdit(true);
end;
procedure TTaskForm.NewMSG();
begin
if (dsTask.RecordCount = 0) then
Exit;
if dsTask.FieldByNAme('ID').IsNull then
Exit;
pgcMSG.ActivePage := tsEdit;
dsMSG.Insert;
dsMSG['TASK_ID'] := dsTask['ID'];
mmoTEXT.SetFocus;
end;
procedure TTaskForm.EditTask();
begin
if dsTask.FieldByNAme('ID').IsNull then
Exit;
if dsTask.FieldByNAme('ADDED_BY').IsNull then
Exit;
if (dsTask['ADDED_BY'] = dmMain.User) then
begin
FCanEdit := true;
dsUsers.Open;
if not dsTask.FieldByNAme('COLOR').IsNull then
pnlEdit.COLOR := StringToColor(dsTask['COLOR'])
else
pnlEdit.COLOR := clBtnFace;
SetUsers();
StartEdit(False);
end;
end;
procedure TTaskForm.CancelEditMsg();
begin
dsMSG.Cancel;
pgcMSG.ActivePage := tsGrid;
dbgMsg.SetFocus;
end;
procedure TTaskForm.SaveUsers;
begin
if mtbUsers.State in [dsEdit] then
mtbUsers.Post;
mtbUsers.DisableControls;
mtbUsers.First;
with TpFIBQuery.Create(Nil) do
begin
try
Database := dmMain.dbTV;
Transaction := dmMain.trWriteQ;
sql.Text := 'delete from Taskuser where Task_Id = :task_id';
ParamByName('task_id').AsInteger := dsTask['ID'];
Transaction.StartTransaction;
ExecQuery;
Transaction.Commit;
sql.Text := 'insert into Taskuser (Task_Id, Foruser) values (:Task_Id, :Ibname)';
while not mtbUsers.Eof do
begin
if (mtbUsers['in_task']) then
begin
ParamByName('task_id').AsInteger := dsTask['ID'];
ParamByName('Ibname').AsString := mtbUsers['IBNAME'];
Transaction.StartTransaction;
ExecQuery;
Transaction.Commit;
end;
mtbUsers.Next;
end;
mtbUsers.First;
finally
Free;
end;
end;
mtbUsers.EnableControls;
// dsUsers.Close;
end;
procedure TTaskForm.GetUsers;
begin
mtbUsers.Open;
mtbUsers.DisableControls;
with TpFIBQuery.Create(Nil) do
begin
try
Database := dmMain.dbTV;
Transaction := dmMain.trReadQ;
sql.Text := 'select w.Surname || coalesce('' ''||w.Firstname, '''') FIO , w.Ibname ' +
'from worker w where not (w.Ibname is null) and (w.Working = 1) order by 1';
Transaction.StartTransaction;
ExecQuery;
while not Eof do
begin
mtbUsers.Append;
mtbUsers['FIO'] := FN('FIO').AsString;
mtbUsers['Ibname'] := FN('Ibname').AsString;
mtbUsers['IN_TASK'] := False;
mtbUsers.Post;
Next;
end;
Close;
Transaction.Commit;
mtbUsers.First;
finally
Free;
end;
end;
mtbUsers.EnableControls;
end;
procedure TTaskForm.SetUsers(const new: Boolean = False);
begin
mtbUsers.DisableControls;
mtbUsers.First;
while not mtbUsers.Eof do
begin
mtbUsers.Edit;
mtbUsers['IN_TASK'] := False;
mtbUsers.Post;
mtbUsers.Next;
end;
if not new then
with TpFIBQuery.Create(Nil) do
begin
try
Database := dmMain.dbTV;
Transaction := dmMain.trReadQ;
sql.Text := 'select Foruser from Taskuser where Task_Id = :Task_Id';
ParamByName('task_id').AsInteger := dsTask['ID'];
Transaction.StartTransaction;
ExecQuery;
while not Eof do
begin
if mtbUsers.Locate('IBNAME', FN('Foruser').AsString, []) then
begin
mtbUsers.Edit;
mtbUsers['IN_TASK'] := true;
mtbUsers.Post;
end;
Next;
end;
Close;
Transaction.Commit;
finally
Free;
end;
end;
mtbUsers.First;
mtbUsers.EnableControls;
end;
procedure TTaskForm.srcDataSourceDataChange(Sender: TObject; Field: TField);
begin
inherited;
if FCanClose then
begin
if (dsTask.RecordCount > 0) then
actClose.Enabled := (not dsTask.FieldByNAme('CANCLOSE').IsNull)
else
actClose.Enabled := False;
end;
end;
procedure TTaskForm.GoObject;
begin
inherited;
if (dsTask.RecordCount = 0) or (dsMSG.RecordCount = 0) then
Exit;
if (dsMSG.FieldByNAme('OBJ_ID').IsNull) or (dsMSG.FieldByNAme('OBJ_TYPE').IsNull) then
Exit;
A4MainForm.SearchFromTask(dsMSG['OBJ_TYPE'], dsMSG['OBJ_ID']);
end;
procedure TTaskForm.GoObjects;
var
ObjList: TStringList;
s: string;
begin
inherited;
if (dsTask.RecordCount = 0) or (dsMSG.RecordCount = 0) then
Exit;
dsMSG.DisableControls;
dsMSG.First;
ObjList := TStringList.Create;
try
ObjList.Sorted := true;
ObjList.Duplicates := dupIgnore;
while not dsMSG.Eof do
begin
if (not dsMSG.FieldByNAme('OBJ_TYPE').IsNull) and (dsMSG['OBJ_TYPE'] = 'A') and
(not dsMSG.FieldByNAme('OBJ_ID').IsNull) then
ObjList.Add(dsMSG['OBJ_ID']);
dsMSG.Next;
end;
if (ObjList.Count > 0) then
s := ObjList.CommaText
else
s := '';
finally
FreeAndNil(ObjList);
end;
dsMSG.First;
dsMSG.EnableControls;
if (s <> '') then
A4MainForm.SearchFromTask('ALL_CUST', s);
end;
procedure TTaskForm.DeleteMSG();
begin
if (dsTask.RecordCount = 0) or (dsMSG.RecordCount = 0) then
Exit;
if dsMSG.FieldByNAme('ID').IsNull then
Exit;
if not dsTask.FieldByNAme('EXEC_DATE').IsNull then
Exit;
if (dmMain.User <> dsMSG['Added_By']) or (dmMain.User <> dsTask['Added_By']) then
Exit;
if dsMSG.FieldByNAme('TEXT').IsNull then
dsMSG.Delete
else
begin
if (MessageDlg(Format(rsDeleteRecord, [dsMSG.FieldByNAme('TEXT').AsString]), mtConfirmation, [mbYes, mbNo], 0)
= mrYes) then
dsMSG.Delete;
end;
end;
function TTaskForm.GenerateFilter: string;
var
RecordFtr: string;
filter: TStrings;
cr: integer;
procedure addToFilter(const s: string);
var
clears: string;
begin
clears := StringReplace(s, ' ', '', [rfReplaceAll]);
if clears <> '()' then
begin
if RecordFtr <> '' then
RecordFtr := RecordFtr + ' and ' + s
else
RecordFtr := s;
end;
end;
function RecordToFilter: String;
var
eperiod: String;
begin
Result := '';
if (not dsFilter.FieldByNAme('TASK_ID').IsNull) then
addToFilter(Format(' (t.ID = %d)', [dsFilter.FieldByNAme('TASK_ID').AsInteger]));
if (dsFilter.FieldByNAme('ALLUSERS').IsNull) or (not dsFilter['ALLUSERS']) then
addToFilter('((Added_By = current_user) or ' +
'(exists(select tu.Foruser from Taskuser tu where tu.Task_Id = t.Id and (tu.Foruser = current_user or tu.Foruser = ''ALL'' ))))');
if (not dsFilter.FieldByNAme('NotClosed').IsNull) and (dsFilter['NotClosed']) then
addToFilter('t.EXEC_DATE is null');
// Фильтр по исполнителю
if (not dsFilter.FieldByNAme('WORKER').IsNull) then
addToFilter
(Format(' (exists(select tu.Foruser from Taskuser tu where tu.Task_Id = t.Id and tu.Foruser = ''%s''))',
[dsFilter.FieldByNAme('WORKER').AsString]));
eperiod := '';
if (not dsFilter.FieldByNAme('EXEC_FROM').IsNull) then
eperiod := Format('t.EXEC_DATE >= CAST(''%s'' AS DATE)', [FormatDateTime('yyyy-mm-dd', dsFilter['EXEC_FROM'])]);
if (not dsFilter.FieldByNAme('EXEC_TO').IsNull) then
begin
if eperiod <> '' then
eperiod := eperiod + ' and ';
eperiod := eperiod + Format('t.EXEC_DATE < dateadd(DAY, 1, Cast(''%s'' as DATE))',
[FormatDateTime('yyyy-mm-dd', dsFilter['EXEC_TO'])]);
end;
if eperiod <> '' then
addToFilter(eperiod);
eperiod := '';
if (not dsFilter.FieldByNAme('PLAN_FROM').IsNull) then
eperiod := Format('t.Plan_Date >= CAST(''%s'' AS DATE)', [FormatDateTime('yyyy-mm-dd', dsFilter['PLAN_FROM'])]);
if (not dsFilter.FieldByNAme('PLAN_TO').IsNull) then
begin
if eperiod <> '' then
eperiod := eperiod + ' and ';
eperiod := eperiod + Format('t.Plan_Date < dateadd(DAY, 1, Cast(''%s'' as DATE))',
[FormatDateTime('yyyy-mm-dd', dsFilter['PLAN_TO'])]);
end;
if (not dsFilter.FieldByNAme('OBJ_ID').IsNull) and (not dsFilter.FieldByNAme('OBJ_TYPE').IsNull) then
begin
addToFilter
(Format(' (exists(select m.task_id from taskmsg m where m.obj_id = ''%s'' and m.obj_type = ''%s'' and m.task_id = t.id))',
[dsFilter.FieldByNAme('OBJ_ID').AsString, dsFilter.FieldByNAme('OBJ_TYPE').AsString]));
end;
if (not dsFilter.FieldByNAme('NotClosed').IsNull) and (dsFilter['NotClosed']) then
addToFilter('t.EXEC_DATE is null');
if eperiod <> '' then
addToFilter(eperiod);
end;
begin
Result := '';
if (dsFilter.RecordCount = 0) then
Exit;
filter := TStringList.Create;
try
dsFilter.First;
filter.Clear;
cr := 0;
while not dsFilter.Eof do
begin
RecordFtr := '';
RecordToFilter;
if dsFilter['inversion'] then
RecordFtr := Format(' NOT ( %s ) ', [RecordFtr]);
if cr <> 0 then
begin
if dsFilter['next_condition'] = 0 then
RecordFtr := Format(' or ( %s )', [RecordFtr])
else
RecordFtr := Format(' and ( %s )', [RecordFtr]);
filter.Add(RecordFtr);
end
else
filter.Text := Format('( %s )', [RecordFtr]);
inc(cr);
dsFilter.Next;
end;
RecordFtr := filter.Text.Trim;
if RecordFtr <> '( )' then
Result := Format(' and ( %s ) ', [filter.Text]);
finally
filter.Free;
end;
end;
procedure TTaskForm.SetDefaultFilter;
var
f: string;
begin
dsFilter.Close;
dsFilter.Open;
dsFilter.EmptyTable;
f := A4MainForm.GetUserFilterFolder + 'TaskDefault.rf';
if FileExists(f) then
begin
DatasetFromINI(dsFilter, f);
dsTask.ParamByName('Filter').Value := GenerateFilter;
end
else
begin
dsFilter.Insert;
dsFilter['NotClosed'] := true;
dsFilter.Post;
dsTask.ParamByName('Filter').Value := GenerateFilter;
end;
end;
procedure TTaskForm.FindId(const Value: integer);
begin
if (Value <> -1) and dsTask.Active then
begin
if dsTask.Locate('ID', Value, []) then
begin
dbGrid.RowDetailPanel.Visible := true;
dbGrid.RowDetailPanel.Active := true;
dbgMsg.SetFocus;
end
else
begin
//
dsFilter.Close;
dsFilter.Open;
dsFilter.EmptyTable;
dsFilter.Insert;
dsFilter.FieldByNAme('TASK_ID').AsInteger := Value;
dsFilter['NotClosed'] := False;
dsFilter['ALLUSERS'] := dmMain.AllowedAction(rght_Tasks_All);
dsFilter.Post;
dsTask.Close;
dsTask.ParamByName('Filter').Value := GenerateFilter;
dsTask.Open;
end;
end;
end;
procedure TTaskForm.CloseSelectedAsCurrent;
var
i, id: integer;
ed: TDateTime;
begin
if (dsTask.FieldByNAme('Exec_Date').IsNull) then
Exit;
if MessageDlg(rsCloseSelectedTask, mtConfirmation, [mbYes, mbNo], 0) = mrNo then
Exit;
id := dsTask['Id'];
// ed := edtEXEC_DATE.Value; //
ed := dsTask['Exec_Date'];
dbGrid.DataSource.DataSet.DisableControls;
with TpFIBQuery.Create(Nil) do
begin
try
Database := dmMain.dbTV;
Transaction := dmMain.trWriteQ;
sql.Text := 'update Tasklist set Exec_Date = :ed where Id = :id and Exec_Date is null';
ParamByName('ed').AsDateTime := ed;
Transaction.StartTransaction;
for i := 0 to dbGrid.SelectedRows.Count - 1 do
begin
dbGrid.DataSource.DataSet.Bookmark := dbGrid.SelectedRows[i];
ParamByName('id').AsInteger := dbGrid.DataSource.DataSet['ID'];
ExecQuery;
end;
Transaction.Commit;
finally
Free;
end;
end;
dbGrid.DataSource.DataSet.EnableControls;
dsTask.CloseOpen(true);
dsTask.Locate('id', id, []);
end;
end.
|
{| Unit: pmavio
| Version: 1.00
| translated from file pmavio.H
| Original translation: Peter Sawatzki (ps)
| Contributing:
| (fill in)
|
| change history:
| Date: Ver: Author:
| 11/19/93 1.00 ps original translation by ps
}
Unit pmavio;
Interface
Uses
Os2Def,
PmWin;
{**************************************************************************\
*
* Module Name: PMAVIO.H
*
* OS/2 Presentation Manager AVIO constants, types and function declarations
*
\**************************************************************************}
{ common types, constants and function declarations }
Type
HVPS = USHORT; { hpvs }
pHVPS = ^HVPS; { phpvs }
Function VioAssociate (hdc: HDC; hvps: HVPS): USHORT;
Function VioCreateLogFont (pfatattrs: PFATTRS; llcid: LongInt; pName: PSTR8;hvps: HVPS): USHORT;
Function VioCreatePS (phvps: PHVPS; sdepth,swidth,sFormat,sAttrs: SHORT;hvpsReserved: HVPS): USHORT;
Function VioDeleteSetId (llcid: LongInt; hvps: HVPS): USHORT;
Function VioDestroyPS (hvps: HVPS): USHORT;
Function VioGetDeviceCellSize (psHeight,psWidth: PSHORT; hvps: HVPS): USHORT;
Function VioGetOrg (psRow,psColumn: PSHORT; hvps: HVPS): USHORT;
Function VioQueryFonts (plRemfonts: PLONG; afmMetrics: PFONTMETRICS; lMetricsLength: LongInt;
plFonts: PLONG; pszFacename: PSZ; flOptions: ULONG;hvps: HVPS): USHORT;
Function VioQuerySetIds (allcids: PLONG; pNames: PSTR8; alTypes: PLONG;lcount: LongInt;hvps: HVPS): USHORT;
Function VioSetDeviceCellSize (sHeight,sWidth: SHORT; hvps: HVPS): USHORT;
Function VioSetOrg (sRow,sColumn: SHORT; hvps: HVPS): USHORT;
Function VioShowPS (sDepth,sWidth,soffCell: SHORT; hvps: HVPS): USHORT;
{*********************** Public Function ******************************\
* WinDefAVioWindowProc -- Default message processing for AVio PS's
\**********************************************************************}
Function WinDefAVioWindowProc (hwnd: HWND;msg: USHORT; mp1,mp2: MPARAM): MRESULT;
Implementation
Function VioAssociate; External 'VIOCALLS' Index 55;
Function VioCreateLogFont; External 'VIOCALLS' Index 60;
Function VioCreatePS; External 'VIOCALLS' Index 56;
Function VioDeleteSetId; External 'VIOCALLS' Index 57;
Function VioDestroyPS; External 'VIOCALLS' Index 61;
Function VioGetDeviceCellSize; External 'VIOCALLS' Index 58;
Function VioGetOrg; External 'VIOCALLS' Index 59;
Function VioQueryFonts; External 'VIOCALLS' Index 64;
Function VioQuerySetIds; External 'VIOCALLS' Index 62;
Function VioSetDeviceCellSize; External 'VIOCALLS' Index 65;
Function VioSetOrg; External 'VIOCALLS' Index 63;
Function VioShowPS; External 'VIOCALLS' Index 66;
Function WinDefAVioWindowProc; External 'PMVIOP' Index 30;
End.
|
unit AceStr;
{ ----------------------------------------------------------------
Ace Reporter
Copyright 1995-2005 SCT Associates, Inc.
Written by Kevin Maher, Steve Tyrakowski
---------------------------------------------------------------- }
interface
{$I ace.inc}
uses classes;
type
TAceStream = class(TStream)
private
FMemoryStream: TMemoryStream;
FFileStream: TFileStream;
FTempFileName: String;
FStreamPos:{$IFDEF VCL180PLUS} Int64 {$ELSE} LongInt {$ENDIF};
FStreamSize: {$IFDEF VCL180PLUS} Int64 {$ELSE} LongInt {$ENDIF};
FMaxMemUsage: LongInt;
FFileStreamSize: {$IFDEF VCL180PLUS} Int64 {$ELSE} LongInt {$ENDIF};
FBufferStream: TMemoryStream;
FBufferStart, FBufferEnd: {$IFDEF VCL180PLUS} Int64 {$ELSE} LongInt {$ENDIF};
protected
function GetFileStream: TFileStream;
property MemoryStream: TMemoryStream read FMemoryStream write FMemoryStream;
property FileStream: TFileStream read GetFileStream write FFileStream;
procedure Update;
procedure DumpToFile;
public
constructor Create; virtual;
destructor Destroy; override;
function Read(var Buffer; Count: LongInt): LongInt; override;
function Write(const Buffer; Count: LongInt ): LongInt ; override;
{$IFDEF VCL180PLUS}
function Seek(const Offset: Int64 ; Origin: TSeekOrigin): Int64; override;
{$ELSE}
function Seek(Offset: LongInt; Origin: word): LongInt; override;
{$ENDIF}
procedure Clear;
property MaxMemUsage: LongInt read FMaxMemUsage write FMaxMemUsage;
end;
var
AceMaximumMemoryUsage: LongInt ;
implementation
uses {$IFDEF VCL140PLUS} windows, {$ENDIF} aceutil, sysutils;
constructor TAceStream.Create;
begin
inherited Create;
FMemoryStream := TMemoryStream.Create;
FBufferStream := TMemoryStream.Create;
FBufferStart := 0;
FBufferEnd := 0;
FStreamPos := 0;
FStreamSize := 0;
FFileStreamSize := 0;
FMaxMemUsage := AceMaximumMemoryUsage;
end;
destructor TAceStream.Destroy;
begin
Clear;
if ( FBufferStream <> nil ) then FBufferStream.free;
if ( FMemoryStream <> nil ) then FMemoryStream.free;
inherited destroy;
end;
function TAceStream.GetFileStream: TFileStream;
begin
if ( FFileStream = nil ) then
begin
FTempFileName := AceGetTempFile('Ace');
FFileStream := TFileStream.Create(FTempFileName, fmCreate);
end;
result := FFileStream;
end;
function TAceStream.Read(var Buffer; Count: LongInt ): LongInt;
var
ReadIn: LongInt;
begin
if ( FFileStream = nil ) then
begin
FMemoryStream.Position := FStreamPos;
result := FMemoryStream.Read(Buffer, Count);
FStreamPos := FMemoryStream.Position;
end else
begin
if ( FStreamPos >= FFileStreamSize ) then
begin
FMemoryStream.Position := FStreamPos - FFileStream.Size;
result := FMemoryStream.Read(buffer, Count);
FStreamPos := FMemoryStream.Position + FFileStream.Size;
end else
begin
if FMemoryStream.Size > 0 then DumpToFile;
if (FBufferStream.Size = 0) or (FBufferStart > FStreamPos) or
(FBufferEnd < (FStreamPos + Count)) then
begin
FBufferStream.Clear;
FBufferStart := FStreamPos;
ReadIn := 10000;
if Count > ReadIn then ReadIn := Count;
if ReadIn > (FFileStreamSize - FStreamPos) then ReadIn := (FFileStreamSize - FStreamPos);
FBufferEnd := FStreamPos + ReadIn;
FFileStream.Position := FStreamPos;
FBufferStream.CopyFrom(FFileStream, ReadIn)
end;
FBufferStream.Position := FStreamPos-FBufferStart;
result := FBufferStream.Read(buffer, Count);
FStreamPos := FStreamPos + Count;
end;
end;
end;
function TAceStream.Write(const Buffer; Count: LongInt): LongInt;
begin
Update;
if ( FFileStream = nil ) then
begin
FMemoryStream.Position := FStreamPos;
result := FMemoryStream.Write(Buffer, Count);
FStreamPos := FMemoryStream.Position;
FStreamSize := FMemorystream.Size;
end else
begin
if ( FStreamPos >= FFileStreamSize ) then
begin
FMemoryStream.Position := FStreamPos - FFileStreamSize;
result := FMemoryStream.Write(buffer, Count);
FStreamSize := FMemoryStream.Size + FFileStreamSize;
FStreamPos := FFileStreamSize + FMemoryStream.Position;
end else
begin
DumpToFile;
FFileStream.Position := FStreamPos;
result := FFileStream.Write(buffer, Count);
FStreamSize := FFileStream.Size;
FStreamPos := FFileStream.Position;
end;
end;
end;
procedure TAceStream.Update;
begin
if ( FMemoryStream.Size > FMaxMemUsage ) then
begin
DumpToFile;
end;
end;
procedure TAceStream.DumpToFile;
begin
if FMemoryStream.Size > 0 then
begin
FileStream.Position := FileStream.Size;
FileStream.CopyFrom(FMemoryStream, 0); { zero means copy entire stream }
FMemoryStream.Clear;
FFileStreamSize := FStreamSize;
end;
end;
{$IFDEF VCL180PLUS}
function TAceStream.Seek(const Offset: Int64 ; Origin: TSeekOrigin): Int64;
{$ELSE}
function TAceStream.Seek(Offset: LongInt; Origin: word): LongInt;
{$ENDIF}
begin
case ( Origin ) of
{$IFDEF VCL180PLUS}soBeginning{$ELSE}0{$ENDIF}: FStreamPos := Offset;
{$IFDEF VCL180PLUS}soCurrent{$ELSE}1{$ENDIF}: Inc(FStreamPos, Offset);
{$IFDEF VCL180PLUS}soEnd{$ELSE}2{$ENDIF}: FStreamPos := FStreamSize + Offset;
end;
result := FStreamPos;
end;
procedure TAceStream.Clear;
begin
FStreamPos := 0;
FStreamSize := 0;
FMemoryStream.Clear;
FBufferStart := 0;
FBufferEnd := 0;
FBufferStream.Clear;
if ( FFileStream <> nil ) then
begin
FFileStream.free;
sysutils.DeleteFile(FTempFileName);
FFileStream := nil;
FTempFileName := '';
FFileStreamSize := 0;
end;
end;
initialization
AceMaximumMemoryUsage := 512000;
end.
|
unit MvvmClasses;
{$mode objfpc}{$H+}
interface
uses
Windows, Classes, Controls, Contnrs, SyncObjs, MvvmInterfaces;
const
CM_MVVM = CM_BASE + 100;
CM_SOURCECHANGED = CM_MVVM + 1;
type
TInterfacedHelper = class(IUnknown)
protected
function QueryInterface(constref IID: TGUID; out Obj): HResult; stdcall;
function _AddRef: integer; stdcall;
function _Release: integer; stdcall;
end;
TViewModel = class(TInterfacedHelper, IViewModel, IEventSource, IBindingSource)
protected
procedure PropertyChanged(const PropertyName: string);
public
destructor Destroy(); override;
function GetProperty(const PropertyName: string) : string; virtual;
end;
TEventManager = class
private
FListeners : TObjectList;
FSection : TCriticalSection;
FMessages : TStringList;
public
class function Current() : TEventManager;
constructor Create();
destructor Destroy(); override;
procedure AddListener(const Listener: IEventListener; ListeningWindow: HWND; const Source: IEventSource = nil);
function GetMessage(MessageID: integer): string;
procedure Notify(const Source: IEventSource; MessageID: integer; const MessageText: string);
procedure RemoveListener(const Listener: IEventListener; const Source: IEventSource = nil);
procedure RemoveSource(const Source: IEventSource);
end;
implementation
type
TListenPair = class
Window : HWND;
Listener : IEventListener;
Source : IEventSource;
end;
var
FManager : TEventManager;
{ TInterfacedHelper }
function TInterfacedHelper.QueryInterface(constref IID: TGUID; out Obj): HResult; stdcall;
begin
if GetInterface(IID, Obj) then
Result := 0
else
Result := E_NOINTERFACE;
end;
function TInterfacedHelper._AddRef: integer; stdcall;
begin
Result := 1;
end;
function TInterfacedHelper._Release: integer; stdcall;
begin
Result := 1;
end;
{ TViewModel }
destructor TViewModel.Destroy();
begin
TEventManager.Current.RemoveSource(Self);
inherited;
end;
procedure TViewModel.PropertyChanged(const PropertyName: string);
begin
TEventManager.Current.Notify(Self, CM_SOURCECHANGED, PropertyName);
end;
function TViewModel.GetProperty(const PropertyName: string) : string;
begin
// Воспользоваться RTTI для published свойств!
Result := '';
end;
{ TEventManager }
class function TEventManager.Current() : TEventManager;
begin
Result := FManager;
end;
constructor TEventManager.Create();
begin
inherited;
FSection := TCriticalSection.Create();
FListeners := TObjectList.Create();
FMessages := TStringList.Create();
end;
destructor TEventManager.Destroy();
begin
FMessages.Free();
FListeners.Free();
FSection.Free();
inherited;
end;
procedure TEventManager.AddListener(const Listener: IEventListener; ListeningWindow: HWND; const Source: IEventSource = nil);
var
i : integer;
ListenPair : TListenPair;
begin
FSection.Enter();
try
for i:=0 to FListeners.Count-1 do
begin
ListenPair := FListeners[i] as TListenPair;
if (ListenPair.Listener = Listener) and (ListenPair.Source = Source) then
begin
ListenPair.Window := ListeningWindow;
exit;
end;
end;
ListenPair := TListenPair.Create();
ListenPair.Window := ListeningWindow;
ListenPair.Listener := Listener;
ListenPair.Source := Source;
FListeners.Add(ListenPair);
finally
FSection.Release();
end;
end;
procedure TEventManager.RemoveListener(const Listener: IEventListener; const Source: IEventSource = nil);
var
i : integer;
ListenPair : TListenPair;
begin
FSection.Enter();
try
for i:=FListeners.Count-1 downto 0 do
begin
ListenPair := FListeners[i] as TListenPair;
if (ListenPair.Listener = Listener) and ((ListenPair.Source = Source) or (Source = nil)) then
begin
FListeners.Delete(i);
if (Source <> nil) then break;
end;
end;
finally
FSection.Release();
end;
end;
procedure TEventManager.RemoveSource(const Source: IEventSource);
var
i : integer;
ListenPair : TListenPair;
begin
FSection.Enter();
try
for i:=FListeners.Count-1 downto 0 do
begin
ListenPair := FListeners[i] as TListenPair;
if (ListenPair.Source = Source) then
FListeners.Delete(i);
end;
finally
FSection.Release();
end;
end;
procedure TEventManager.Notify(const Source: IEventSource; MessageID: integer; const MessageText: string);
var
i, TextID : integer;
ListenPair : TListenPair;
begin
FSection.Enter();
try
TextID := FMessages.IndexOf(MessageText);
if (TextID < 0) then
TextID := FMessages.Add(MessageText);
for i:=0 to FListeners.Count-1 do
begin
ListenPair := FListeners[i] as TListenPair;
if (ListenPair.Source = Source) or (ListenPair.Source = nil) then
PostMessage(ListenPair.Window, MessageID, 0, TextID);
end;
finally
FSection.Release();
end;
end;
function TEventManager.GetMessage(MessageID: integer): string;
begin
FSection.Enter();
try
if (MessageID < 0) or (MessageID >= FMessages.Count) then
Result := ''
else
Result := FMessages[MessageID];
finally
FSection.Release();
end;
end;
initialization
FManager := TEventManager.Create();
finalization
FManager.Free();
end.
|
unit Unit39;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls;
type
TForm39 = class(TForm)
Memo1: TMemo;
Button1: TButton;
Button2: TButton;
Panel1: TPanel;
Label1: TLabel;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
procedure PopularALista(FList: TList);
public
{ Public declarations }
end;
var
Form39: TForm39;
implementation
{$R *.dfm}
uses DB;
{
Class Helper - Anonimous ComponentsLoop
Amarildo Lacerda
}
type
TComponentHelper = class Helper for TComponent
public
procedure ComponentsLoop(AProc: TProc<TComponent>; AChild: boolean = false);
procedure ListLoop(AList: TList; AProc: TProc<TObject>);
end;
{ TComponentHelper }
procedure TComponentHelper.ListLoop(AList: TList; AProc: TProc<TObject>);
var
i: integer;
begin
for i := 0 to AList.Count - 1 do
AProc(AList[i]);
end;
procedure TComponentHelper.ComponentsLoop(AProc: TProc<TComponent>; AChild: boolean = false);
var
i: integer;
begin
if assigned(AProc) then
for i := 0 to ComponentCount - 1 do
begin
AProc(Components[i]);
if AChild and (Components[i].ComponentCount > 0) then
Components[i].ComponentsLoop(AProc, AChild);
end;
end;
procedure TForm39.Button1Click(Sender: TObject);
begin
Memo1.Lines.Clear;
ComponentsLoop(
Procedure(AComp: TComponent)
begin
Memo1.Lines.Add(AComp.ClassName + '.' + AComp.name);
// fecha todos os TDataset (TQuery)
if AComp is TDataset then
with AComp as TDataset do
close;
end, false);
end;
procedure TForm39.Button2Click(Sender: TObject);
begin
Memo1.Lines.Clear;
ComponentsLoop(
Procedure(AComp: TComponent)
begin
Memo1.Lines.Add(AComp.ClassName + '.' + AComp.name);
end, true);
end;
procedure TForm39.Button3Click(Sender: TObject);
var
FList: TList;
begin
memo1.Lines.Clear;
FList := TList.create;
try
PopularALista(FList);
// fazer um LOOP usando Anonimous
ListLoop(FList,
procedure(AObj: TObject)
begin
memo1.Lines.Add( AObj.ClassName );
end);
finally
FList.Free;
end;
end;
procedure TForm39.PopularALista(FList: TList);
begin
ComponentsLoop(
procedure(cmp: TComponent)
begin
FList.Add(cmp);
end);
end;
end.
|
unit HintBox;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, InternationalizerComponent;
type
THintBoxWindow = class(TForm)
Frame : TShape;
Text : TLabel;
InternationalizerComponent1: TInternationalizerComponent;
procedure FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure FormShow(Sender: TObject);
procedure FormKeyPress(Sender: TObject; var Key: Char);
private
procedure SetHintText( HintText : string );
public
property HintText : string write SetHintText;
end;
var
HintBoxWindow: THintBoxWindow;
implementation
{$R *.DFM}
procedure THintBoxWindow.SetHintText( HintText : string );
begin
Text.Caption := HintText;
Width := Text.Width + 2*Text.Left;
Height := Text.Height + 2*Text.Top;
end;
procedure THintBoxWindow.FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
MouseCapture := false;
Hide;
end;
procedure THintBoxWindow.FormShow(Sender: TObject);
begin
MouseCapture := true;
end;
procedure THintBoxWindow.FormKeyPress(Sender: TObject; var Key: Char);
begin
MouseCapture := false;
Hide;
end;
end.
|
unit nsRubricatorList;
{* Структура "одноуровневое дерево" для узла рубрикатора }
// Модуль: "w:\garant6x\implementation\Garant\GbaNemesis\Rubricator\nsRubricatorList.pas"
// Стереотип: "SimpleClass"
// Элемент модели: "TnsRubricatorList" MUID: (46836A280235)
{$Include w:\garant6x\implementation\Garant\nsDefine.inc}
interface
{$If NOT Defined(Admin) AND NOT Defined(Monitorings)}
uses
l3IntfUses
, nsOneLevelTreeStruct
, RubricatorInterfaces
, DynamicTreeUnit
, MainMenuUnit
;
type
TnsRubricatorList = class(TnsOneLevelTreeStruct, InsRubricatorTree)
{* Структура "одноуровневое дерево" для узла рубрикатора }
private
f_FrozenRoot: INodeBase;
f_RootToKeep: INodeBase;
f_MenuSectionItemToKeep: ISectionItem;
protected
function ReAqurieUnfilteredRoot: INodeBase; override;
function Get_RootToKeep: INodeBase;
function Get_MenuSectionItemToKeep: ISectionItem;
procedure ClearFields; override;
public
constructor CreateKeeped(const aRoot: INodeBase;
const aRootToKeep: INodeBase;
const aMenuSectionItemToKeep: ISectionItem); reintroduce;
class function Make(const aRoot: INodeBase;
const aRootToKeep: INodeBase;
const aMenuSectionItemToKeep: ISectionItem): InsRubricatorTree; reintroduce;
constructor Create(const aRoot: INodeBase;
aShowRoot: Boolean;
aOneLevel: Boolean = False); override;
end;//TnsRubricatorList
{$IfEnd} // NOT Defined(Admin) AND NOT Defined(Monitorings)
implementation
{$If NOT Defined(Admin) AND NOT Defined(Monitorings)}
uses
l3ImplUses
, nsRubricatorCache
, nsNodes
{$If NOT Defined(NoVCM)}
, vcmBase
{$IfEnd} // NOT Defined(NoVCM)
{$If NOT Defined(NoVCM)}
, StdRes
{$IfEnd} // NOT Defined(NoVCM)
, l3Tree_TLB
, l3TreeInterfaces
, nsTypes
, SysUtils
//#UC START# *46836A280235impl_uses*
//#UC END# *46836A280235impl_uses*
;
constructor TnsRubricatorList.CreateKeeped(const aRoot: INodeBase;
const aRootToKeep: INodeBase;
const aMenuSectionItemToKeep: ISectionItem);
//#UC START# *4E7387AE0021_46836A280235_var*
//#UC END# *4E7387AE0021_46836A280235_var*
begin
//#UC START# *4E7387AE0021_46836A280235_impl*
Create(aRoot, false);
f_RootToKeep := aRootToKeep;
//#UC END# *4E7387AE0021_46836A280235_impl*
end;//TnsRubricatorList.CreateKeeped
class function TnsRubricatorList.Make(const aRoot: INodeBase;
const aRootToKeep: INodeBase;
const aMenuSectionItemToKeep: ISectionItem): InsRubricatorTree;
var
l_Inst : TnsRubricatorList;
begin
l_Inst := CreateKeeped(aRoot, aRootToKeep, aMenuSectionItemToKeep);
try
Result := l_Inst;
finally
l_Inst.Free;
end;//try..finally
end;//TnsRubricatorList.Make
function TnsRubricatorList.ReAqurieUnfilteredRoot: INodeBase;
//#UC START# *48FF64F60078_46836A280235_var*
var
l_RubricatorRoot,
l_Child1, l_Child2: INodeBase;
l_l3Root, l_l3Node: Il3Node;
l_SimpleRootNode: Il3SimpleRootNode;
//#UC END# *48FF64F60078_46836A280235_var*
begin
//#UC START# *48FF64F60078_46836A280235_impl*
case BeenReseted of
rtsRoot :
begin
Result := nil;
l_RubricatorRoot := TnsRubricatorCache.Instance.RubricatorRoot;
if (l_RubricatorRoot <> nil) then
if (f_FrozenRoot <> nil) then
l_RubricatorRoot.FindNode(f_FrozenRoot, Result)
else
begin
// откроем первую ветку рубрикатора
l_RubricatorRoot.GetFirstChild(l_Child1);
if (l_Child1 <> nil) then
begin
l_Child1.GetFirstChild(l_Child2);
if (l_Child2 <> nil) then
Result := l_Child2;
end;//l_Child1 <> nil
end;//f_FrozenRoot <> nil
if (Result = nil) then
begin
l_l3Root := TnsCacheableNode.Make(nil);
l_l3Node := TnsCacheableNode.Make(nil);
l_l3Node.Text := vcmCStr(str_InformationUnavailable).AsWStr;
l_l3Root.InsertChild(l_l3Node);
if Supports(l_l3Root, Il3SimpleRootNode, l_SimpleRootNode) then
Root := l_SimpleRootNode;
end;//Result = nil
end;//rtsRoot
else
Result := inherited ReAqurieUnfilteredRoot;
end;//case BeenReseted
if (Result <> nil) then
Result.GetFrozenNode(f_FrozenRoot)
else
f_FrozenRoot := nil;
//#UC END# *48FF64F60078_46836A280235_impl*
end;//TnsRubricatorList.ReAqurieUnfilteredRoot
function TnsRubricatorList.Get_RootToKeep: INodeBase;
//#UC START# *4E7AFF540238_46836A280235get_var*
//#UC END# *4E7AFF540238_46836A280235get_var*
begin
//#UC START# *4E7AFF540238_46836A280235get_impl*
Result := f_RootToKeep;
//#UC END# *4E7AFF540238_46836A280235get_impl*
end;//TnsRubricatorList.Get_RootToKeep
function TnsRubricatorList.Get_MenuSectionItemToKeep: ISectionItem;
//#UC START# *4E7AFFA700A6_46836A280235get_var*
//#UC END# *4E7AFFA700A6_46836A280235get_var*
begin
//#UC START# *4E7AFFA700A6_46836A280235get_impl*
Result := f_MenuSectionItemToKeep;
//#UC END# *4E7AFFA700A6_46836A280235get_impl*
end;//TnsRubricatorList.Get_MenuSectionItemToKeep
constructor TnsRubricatorList.Create(const aRoot: INodeBase;
aShowRoot: Boolean;
aOneLevel: Boolean = False);
//#UC START# *48FDD9270194_46836A280235_var*
//#UC END# *48FDD9270194_46836A280235_var*
begin
//#UC START# *48FDD9270194_46836A280235_impl*
inherited;
if aRoot <> nil then
aRoot.GetFrozenNode(f_FrozenRoot);
//#UC END# *48FDD9270194_46836A280235_impl*
end;//TnsRubricatorList.Create
procedure TnsRubricatorList.ClearFields;
begin
f_FrozenRoot := nil;
f_RootToKeep := nil;
f_MenuSectionItemToKeep := nil;
inherited;
end;//TnsRubricatorList.ClearFields
{$IfEnd} // NOT Defined(Admin) AND NOT Defined(Monitorings)
end.
|
unit evControlGroup;
{* Группа реквизитов (блок параграфов) }
// Модуль: "w:\common\components\gui\Garant\Everest\qf\evControlGroup.pas"
// Стереотип: "SimpleClass"
// Элемент модели: "TevControlGroup" MUID: (48DB819600D8)
{$Include w:\common\components\gui\Garant\Everest\evDefine.inc}
interface
uses
l3IntfUses
, evCustomControlTool
, evQueryCardInt
, evReqList
, evDescriptionReqList
, nevTools
, l3Interfaces
, evdTypes
, nevBase
;
type
TevControlGroup = class(TevCustomControlTool, IevCustomEditorControl, IevQueryGroup)
{* Группа реквизитов (блок параграфов) }
private
f_ReqList: TevReqList;
{* Список реквизитов для каждой группы (IevReq) }
f_DescriptionList: TevDescriptionReqList;
{* Список описаний для каждой группы (IevDescriptionReq) }
f_QueryCard: Pointer;
{* Указатель на контейнер всех виджетов, групп и атрибутов. IevQueryCard }
protected
function IsMultiline: Boolean;
{* Контрол содержит несколько строк и поддерживает перемещение по ним
с помощью стрелок (к меткам это не относится). }
function GetControlIterator: IevControlIterator;
{* Интерфейс "навигатора" по контролам. }
procedure InitBoolProperty(aIdent: Integer;
aValue: Boolean);
{* Для установки начальных значений (не используется передача данных для
процессора операций). }
procedure UpperChange;
{* Обработчик изменения состояния кнопок. }
function Get_ControlName: Tl3WString;
procedure Set_ControlName(const aValue: Tl3WString);
function Get_ControlType: TevControlType;
function Get_Visible: Boolean;
procedure Set_Visible(aValue: Boolean);
function Get_Upper: Boolean;
procedure Set_Upper(aValue: Boolean);
procedure ClickOnDisabledLabel;
procedure AfterCollapsed;
{* Обработчик события сворачивания группы. }
function CanCollapsed: Boolean;
{* Проверка может ли группа свернуться. }
function LMouseBtnDown(const aView: InevControlView;
const aTextPara: InevPara;
const aPt: TnevPoint;
const Keys: TevMouseState;
const aMap: InevMap): Boolean;
{* Обработка нажания на левую кнопку мыши. }
function LMouseBtnUp(const aView: InevControlView;
const aTextPara: InevPara;
const aPt: TnevPoint;
const Keys: TevMouseState): Boolean;
function FindDescriptionReq(const aReqName: Tl3WString): IevDescriptionReq;
{* Возвращает реквизит по имени. }
procedure InitModel(const aTag: InevPara);
{* Инициализация модели. }
function LastReq: IevReq;
{* Последний реквизт в группе. }
function FirstReq: IevReq;
{* Первый реквизит в группе. }
function GetNextReq(const aReq: IevReq): IevReq;
{* Возвращает следующий реквизит. }
function GetPrevReq(const aReq: IevReq): IevReq;
{* Возвращает предыдущий реквизит. }
function Get_Req(Index: Integer): IevReq;
function Get_ReqCount: Integer;
function Get_DescriptionReq(Index: Integer): IevDescriptionReq;
function Get_DescriptionReqCount: Integer;
function Get_GroupName: Il3CString;
function Get_Expanded: Boolean;
procedure Set_Expanded(aValue: Boolean);
function Get_QueryCard: IevQueryCard;
procedure Cleanup; override;
{* Функция очистки полей объекта. }
public
class function Make(const aValue: InevPara;
const aQueryAdapter: IevQueryCard): IevQueryGroup; reintroduce;
constructor Create(const aValue: InevPara;
const aQueryAdapter: IevQueryCard); reintroduce;
end;//TevControlGroup
implementation
uses
l3ImplUses
, k2Tags
, l3Types
, l3Base
, k2OpMisc
, l3String
, evReq
, evDescriptionReq
, nevFacade
, ReqRow_Const
//#UC START# *48DB819600D8impl_uses*
//#UC END# *48DB819600D8impl_uses*
;
class function TevControlGroup.Make(const aValue: InevPara;
const aQueryAdapter: IevQueryCard): IevQueryGroup;
var
l_Inst : TevControlGroup;
begin
l_Inst := Create(aValue, aQueryAdapter);
try
Result := l_Inst;
finally
l_Inst.Free;
end;//try..finally
end;//TevControlGroup.Make
constructor TevControlGroup.Create(const aValue: InevPara;
const aQueryAdapter: IevQueryCard);
//#UC START# *48DB8D660301_48DB819600D8_var*
//#UC END# *48DB8D660301_48DB819600D8_var*
begin
//#UC START# *48DB8D660301_48DB819600D8_impl*
inherited Create(aValue);
f_ReqList := TevReqList.Make;
f_DescriptionList := TevDescriptionReqList.Make;
f_QueryCard := Pointer(aQueryAdapter);
aValue.AsObject.IntA[k2_tiModelControl] := Long(IevQueryGroup(Self));
//#UC END# *48DB8D660301_48DB819600D8_impl*
end;//TevControlGroup.Create
function TevControlGroup.IsMultiline: Boolean;
{* Контрол содержит несколько строк и поддерживает перемещение по ним
с помощью стрелок (к меткам это не относится). }
//#UC START# *47CD5E7A027B_48DB819600D8_var*
//#UC END# *47CD5E7A027B_48DB819600D8_var*
begin
//#UC START# *47CD5E7A027B_48DB819600D8_impl*
Result := False;
//#UC END# *47CD5E7A027B_48DB819600D8_impl*
end;//TevControlGroup.IsMultiline
function TevControlGroup.GetControlIterator: IevControlIterator;
{* Интерфейс "навигатора" по контролам. }
//#UC START# *47CD5E9B031F_48DB819600D8_var*
//#UC END# *47CD5E9B031F_48DB819600D8_var*
begin
//#UC START# *47CD5E9B031F_48DB819600D8_impl*
Result := IevQueryCard(f_QueryCard).GetControlIterator(Self);
//#UC END# *47CD5E9B031F_48DB819600D8_impl*
end;//TevControlGroup.GetControlIterator
procedure TevControlGroup.InitBoolProperty(aIdent: Integer;
aValue: Boolean);
{* Для установки начальных значений (не используется передача данных для
процессора операций). }
//#UC START# *47CD5EB4005D_48DB819600D8_var*
//#UC END# *47CD5EB4005D_48DB819600D8_var*
begin
//#UC START# *47CD5EB4005D_48DB819600D8_impl*
Para.AsObject.BoolW[aIdent, nil] := aValue;
//#UC END# *47CD5EB4005D_48DB819600D8_impl*
end;//TevControlGroup.InitBoolProperty
procedure TevControlGroup.UpperChange;
{* Обработчик изменения состояния кнопок. }
//#UC START# *47CD5EC10294_48DB819600D8_var*
//#UC END# *47CD5EC10294_48DB819600D8_var*
begin
//#UC START# *47CD5EC10294_48DB819600D8_impl*
Get_QueryCard.UpperChange(Self);
//#UC END# *47CD5EC10294_48DB819600D8_impl*
end;//TevControlGroup.UpperChange
function TevControlGroup.Get_ControlName: Tl3WString;
//#UC START# *47CD5EE900F7_48DB819600D8get_var*
//#UC END# *47CD5EE900F7_48DB819600D8get_var*
begin
//#UC START# *47CD5EE900F7_48DB819600D8get_impl*
Result := Para.AsObject.PCharLenA[k2_tiName];
//#UC END# *47CD5EE900F7_48DB819600D8get_impl*
end;//TevControlGroup.Get_ControlName
procedure TevControlGroup.Set_ControlName(const aValue: Tl3WString);
//#UC START# *47CD5EE900F7_48DB819600D8set_var*
//#UC END# *47CD5EE900F7_48DB819600D8set_var*
begin
//#UC START# *47CD5EE900F7_48DB819600D8set_impl*
Para.AsObject.PCharLenW[k2_tiName, nil] := Tl3PCharLen(aValue);
//#UC END# *47CD5EE900F7_48DB819600D8set_impl*
end;//TevControlGroup.Set_ControlName
function TevControlGroup.Get_ControlType: TevControlType;
//#UC START# *47CD5F19011F_48DB819600D8get_var*
//#UC END# *47CD5F19011F_48DB819600D8get_var*
begin
//#UC START# *47CD5F19011F_48DB819600D8get_impl*
Result := ev_ctCollapsedPanel;
//#UC END# *47CD5F19011F_48DB819600D8get_impl*
end;//TevControlGroup.Get_ControlType
function TevControlGroup.Get_Visible: Boolean;
//#UC START# *47CD5F3B03CA_48DB819600D8get_var*
//#UC END# *47CD5F3B03CA_48DB819600D8get_var*
begin
//#UC START# *47CD5F3B03CA_48DB819600D8get_impl*
Result := True;
//#UC END# *47CD5F3B03CA_48DB819600D8get_impl*
end;//TevControlGroup.Get_Visible
procedure TevControlGroup.Set_Visible(aValue: Boolean);
//#UC START# *47CD5F3B03CA_48DB819600D8set_var*
//#UC END# *47CD5F3B03CA_48DB819600D8set_var*
begin
//#UC START# *47CD5F3B03CA_48DB819600D8set_impl*
Assert(false);
//#UC END# *47CD5F3B03CA_48DB819600D8set_impl*
end;//TevControlGroup.Set_Visible
function TevControlGroup.Get_Upper: Boolean;
//#UC START# *47CD5F4F015B_48DB819600D8get_var*
//#UC END# *47CD5F4F015B_48DB819600D8get_var*
begin
//#UC START# *47CD5F4F015B_48DB819600D8get_impl*
Result := Para.AsObject.BoolA[k2_tiUpper];
//#UC END# *47CD5F4F015B_48DB819600D8get_impl*
end;//TevControlGroup.Get_Upper
procedure TevControlGroup.Set_Upper(aValue: Boolean);
//#UC START# *47CD5F4F015B_48DB819600D8set_var*
//#UC END# *47CD5F4F015B_48DB819600D8set_var*
begin
//#UC START# *47CD5F4F015B_48DB819600D8set_impl*
Para.AsObject.BoolW[k2_tiUpper, nil] := aValue;
//#UC END# *47CD5F4F015B_48DB819600D8set_impl*
end;//TevControlGroup.Set_Upper
procedure TevControlGroup.ClickOnDisabledLabel;
//#UC START# *47CD7F53034B_48DB819600D8_var*
//#UC END# *47CD7F53034B_48DB819600D8_var*
begin
//#UC START# *47CD7F53034B_48DB819600D8_impl*
(Get_QueryCard As InevControlListener).HideDroppedControl(True);
//#UC END# *47CD7F53034B_48DB819600D8_impl*
end;//TevControlGroup.ClickOnDisabledLabel
procedure TevControlGroup.AfterCollapsed;
{* Обработчик события сворачивания группы. }
//#UC START# *47CD7F8D00E8_48DB819600D8_var*
//#UC END# *47CD7F8D00E8_48DB819600D8_var*
begin
//#UC START# *47CD7F8D00E8_48DB819600D8_impl*
Get_QueryCard.AfterCollapsed(Self);
//#UC END# *47CD7F8D00E8_48DB819600D8_impl*
end;//TevControlGroup.AfterCollapsed
function TevControlGroup.CanCollapsed: Boolean;
{* Проверка может ли группа свернуться. }
//#UC START# *47CD7F9F006A_48DB819600D8_var*
var
i : Integer;
l_Count : Integer;
//#UC END# *47CD7F9F006A_48DB819600D8_var*
begin
//#UC START# *47CD7F9F006A_48DB819600D8_impl*
Result := Para.AsObject.BoolA[k2_tiFlat];
// ^ http://mdp.garant.ru/pages/viewpage.action?pageId=119473683&focusedCommentId=119473946#comment-119473946
if Result then
begin
l_Count := f_ReqList.Count - 1;
for i := 0 to l_Count do
if not Get_Req(i).IsEmpty then
begin
Result := False;
Break;
end;
end;
//#UC END# *47CD7F9F006A_48DB819600D8_impl*
end;//TevControlGroup.CanCollapsed
function TevControlGroup.LMouseBtnDown(const aView: InevControlView;
const aTextPara: InevPara;
const aPt: TnevPoint;
const Keys: TevMouseState;
const aMap: InevMap): Boolean;
{* Обработка нажания на левую кнопку мыши. }
//#UC START# *47CD7FF40330_48DB819600D8_var*
//#UC END# *47CD7FF40330_48DB819600D8_var*
begin
//#UC START# *47CD7FF40330_48DB819600D8_impl*
(Get_QueryCard As InevControlListener).HideDroppedControl(True);
Result := True;
//#UC END# *47CD7FF40330_48DB819600D8_impl*
end;//TevControlGroup.LMouseBtnDown
function TevControlGroup.LMouseBtnUp(const aView: InevControlView;
const aTextPara: InevPara;
const aPt: TnevPoint;
const Keys: TevMouseState): Boolean;
//#UC START# *47CD802F02AE_48DB819600D8_var*
//#UC END# *47CD802F02AE_48DB819600D8_var*
begin
//#UC START# *47CD802F02AE_48DB819600D8_impl*
Result := True;
if Get_Expanded and not CanCollapsed then
Exit;
with Para do
AsObject.BoolW[k2_tiCollapsed, k2StartOp(aView.Control.Processor)] :=
not AsObject.BoolA[k2_tiCollapsed];
AfterCollapsed;
Para.AsObject.BoolW[k2_tiChecked, nil] := False;
Set_Upper(False);
//#UC END# *47CD802F02AE_48DB819600D8_impl*
end;//TevControlGroup.LMouseBtnUp
function TevControlGroup.FindDescriptionReq(const aReqName: Tl3WString): IevDescriptionReq;
{* Возвращает реквизит по имени. }
//#UC START# *47CD806B02F2_48DB819600D8_var*
var
i : Integer;
l_Count : Integer;
l_Req : IevDescriptionReq;
//#UC END# *47CD806B02F2_48DB819600D8_var*
begin
//#UC START# *47CD806B02F2_48DB819600D8_impl*
Result := nil;
l_Count := f_DescriptionList.Count - 1;
for i := l_Count downto 0 do
begin
l_Req := f_DescriptionList[i];
try
if l3Same(l_Req.ReqName, aReqName, true) then
begin
Result := l_Req;
Break;
end;//l3Same(l_Req.ReqName, aReqName, true)
finally
l_Req := nil;
end;//try..finally
end;//for i
//#UC END# *47CD806B02F2_48DB819600D8_impl*
end;//TevControlGroup.FindDescriptionReq
procedure TevControlGroup.InitModel(const aTag: InevPara);
{* Инициализация модели. }
//#UC START# *47CD807D0057_48DB819600D8_var*
var
l_OldReqName: array [Boolean] of string;
l_ReqList : TevReqList;
l_DescriptionList: TevDescriptionReqList;
function GetChildLine(const aChild: InevPara; Index: Long): Bool;
var
l_CL : IevReq;
l_Name : String;
l_ReqKind : TevReqKind;
l_Enabled : Boolean;
begin
Result := True;
with aChild do
if AsObject.IsKindOf(k2_typReqRow) then
begin
l_Name := aChild.AsObject.Attr[k2_tiReqID].AsString;
l_ReqKind := TevReqKind(aChild.AsObject.IntA[k2_tiReqKind]);
l_Enabled := l_ReqKind <> ev_rkDescription;
aChild.AsObject.BoolW[k2_tiEnabled, nil] := l_Enabled;
if l_Enabled then
begin
if (l_Name = l_OldReqName[true]) then
begin
l_CL := l_ReqList.Last;
try
l_CL.InitModel(aChild, True, -1, -1);
finally
l_CL := nil;
end;//try..finally
end//l_Name = l_OldReqName[true]
else
begin
l_OldReqName[true] := l_Name;
l_ReqList.Add(TevReq.Make(aChild));
end;//l_Name = l_OldReqName[true]
end//l_Enabled
else
begin
if (l_Name = l_OldReqName[false]) then
Assert(False,'Allow only one control for description')
else
begin
l_OldReqName[false] := l_Name;
l_DescriptionList.Add(TevDescriptionReq.Make(aChild));
end;//l_Name = l_OldReqName[false]
end;//l_Enabled
end;//if IsKindOf(k2_typControlBlock)
end;//GetChildLine
//#UC END# *47CD807D0057_48DB819600D8_var*
begin
//#UC START# *47CD807D0057_48DB819600D8_impl*
l_OldReqName[False] := '';
l_OldReqName[True] := '';
l_DescriptionList := f_DescriptionList;
l_ReqList := f_ReqList;
with aTag do
if AsObject.IsValid then
AsList.IterateParaF(nevL2PIA(@GetChildLine));
//#UC END# *47CD807D0057_48DB819600D8_impl*
end;//TevControlGroup.InitModel
function TevControlGroup.LastReq: IevReq;
{* Последний реквизт в группе. }
//#UC START# *47CD80890115_48DB819600D8_var*
//#UC END# *47CD80890115_48DB819600D8_var*
begin
//#UC START# *47CD80890115_48DB819600D8_impl*
Result := f_ReqList.Last;
//#UC END# *47CD80890115_48DB819600D8_impl*
end;//TevControlGroup.LastReq
function TevControlGroup.FirstReq: IevReq;
{* Первый реквизит в группе. }
//#UC START# *47CD8097030D_48DB819600D8_var*
//#UC END# *47CD8097030D_48DB819600D8_var*
begin
//#UC START# *47CD8097030D_48DB819600D8_impl*
Result := f_ReqList.First;
//#UC END# *47CD8097030D_48DB819600D8_impl*
end;//TevControlGroup.FirstReq
function TevControlGroup.GetNextReq(const aReq: IevReq): IevReq;
{* Возвращает следующий реквизит. }
//#UC START# *47CD80A80368_48DB819600D8_var*
var
l_Index: Integer;
//#UC END# *47CD80A80368_48DB819600D8_var*
begin
//#UC START# *47CD80A80368_48DB819600D8_impl*
Result := nil;
if (f_ReqList.Last <> aReq) then
begin
l_Index := f_ReqList.IndexOf(aReq) + 1;
if l_Index < f_ReqList.Count then
Result := f_ReqList[l_Index];
end;
//#UC END# *47CD80A80368_48DB819600D8_impl*
end;//TevControlGroup.GetNextReq
function TevControlGroup.GetPrevReq(const aReq: IevReq): IevReq;
{* Возвращает предыдущий реквизит. }
//#UC START# *47CD80D8028A_48DB819600D8_var*
var
l_Index: Integer;
//#UC END# *47CD80D8028A_48DB819600D8_var*
begin
//#UC START# *47CD80D8028A_48DB819600D8_impl*
Result := nil;
if (f_ReqList.First <> aReq) then
begin
l_Index := f_ReqList.IndexOf(aReq) - 1;
if l_Index >= 0 then
Result := f_ReqList[l_Index];
end;
//#UC END# *47CD80D8028A_48DB819600D8_impl*
end;//TevControlGroup.GetPrevReq
function TevControlGroup.Get_Req(Index: Integer): IevReq;
//#UC START# *47CD80EB0376_48DB819600D8get_var*
//#UC END# *47CD80EB0376_48DB819600D8get_var*
begin
//#UC START# *47CD80EB0376_48DB819600D8get_impl*
Result := f_ReqList[Index];
//#UC END# *47CD80EB0376_48DB819600D8get_impl*
end;//TevControlGroup.Get_Req
function TevControlGroup.Get_ReqCount: Integer;
//#UC START# *47CD810E0258_48DB819600D8get_var*
//#UC END# *47CD810E0258_48DB819600D8get_var*
begin
//#UC START# *47CD810E0258_48DB819600D8get_impl*
Result := f_ReqList.Count;
//#UC END# *47CD810E0258_48DB819600D8get_impl*
end;//TevControlGroup.Get_ReqCount
function TevControlGroup.Get_DescriptionReq(Index: Integer): IevDescriptionReq;
//#UC START# *47CD814902F1_48DB819600D8get_var*
//#UC END# *47CD814902F1_48DB819600D8get_var*
begin
//#UC START# *47CD814902F1_48DB819600D8get_impl*
Result := f_DescriptionList[Index];
//#UC END# *47CD814902F1_48DB819600D8get_impl*
end;//TevControlGroup.Get_DescriptionReq
function TevControlGroup.Get_DescriptionReqCount: Integer;
//#UC START# *47CD817001B4_48DB819600D8get_var*
//#UC END# *47CD817001B4_48DB819600D8get_var*
begin
//#UC START# *47CD817001B4_48DB819600D8get_impl*
Result := f_DescriptionList.Count;
//#UC END# *47CD817001B4_48DB819600D8get_impl*
end;//TevControlGroup.Get_DescriptionReqCount
function TevControlGroup.Get_GroupName: Il3CString;
//#UC START# *47CD8184009F_48DB819600D8get_var*
//#UC END# *47CD8184009F_48DB819600D8get_var*
begin
//#UC START# *47CD8184009F_48DB819600D8get_impl*
Result := l3CStr(Para.AsObject.PCharLenA[k2_tiShortName]);
//#UC END# *47CD8184009F_48DB819600D8get_impl*
end;//TevControlGroup.Get_GroupName
function TevControlGroup.Get_Expanded: Boolean;
//#UC START# *47CD819D0144_48DB819600D8get_var*
//#UC END# *47CD819D0144_48DB819600D8get_var*
begin
//#UC START# *47CD819D0144_48DB819600D8get_impl*
Result := not Para.AsObject.BoolA[k2_tiCollapsed];
//#UC END# *47CD819D0144_48DB819600D8get_impl*
end;//TevControlGroup.Get_Expanded
procedure TevControlGroup.Set_Expanded(aValue: Boolean);
//#UC START# *47CD819D0144_48DB819600D8set_var*
//#UC END# *47CD819D0144_48DB819600D8set_var*
begin
//#UC START# *47CD819D0144_48DB819600D8set_impl*
Para.AsObject.BoolW[k2_tiCollapsed, nil] := not aValue;
//#UC END# *47CD819D0144_48DB819600D8set_impl*
end;//TevControlGroup.Set_Expanded
function TevControlGroup.Get_QueryCard: IevQueryCard;
//#UC START# *47CD81C7029A_48DB819600D8get_var*
//#UC END# *47CD81C7029A_48DB819600D8get_var*
begin
//#UC START# *47CD81C7029A_48DB819600D8get_impl*
Result := IevQueryCard(f_QueryCard);
//#UC END# *47CD81C7029A_48DB819600D8get_impl*
end;//TevControlGroup.Get_QueryCard
procedure TevControlGroup.Cleanup;
{* Функция очистки полей объекта. }
//#UC START# *479731C50290_48DB819600D8_var*
//#UC END# *479731C50290_48DB819600D8_var*
begin
//#UC START# *479731C50290_48DB819600D8_impl*
f_QueryCard := nil;
l3Free(f_ReqList);
l3Free(f_DescriptionList);
inherited;
//#UC END# *479731C50290_48DB819600D8_impl*
end;//TevControlGroup.Cleanup
end.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.