From 8eedd05f0c8c045fe160edcf744802f14629085f Mon Sep 17 00:00:00 2001 From: kichik Date: Sun, 16 Nov 2003 22:38:14 +0000 Subject: [PATCH] Applied patch #838864 - some more optimizations git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@3152 212acab6-be3b-0410-9dea-997c60f758d6 --- Contrib/ExDLL/exdll.dpr | 14 +++++++------- Contrib/ExDLL/exdll_with_unit.dpr | 4 ++-- Contrib/ExDLL/nsis.pas | 26 +++++++++++++------------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Contrib/ExDLL/exdll.dpr b/Contrib/ExDLL/exdll.dpr index 02cba1cf..ec70b108 100644 --- a/Contrib/ExDLL/exdll.dpr +++ b/Contrib/ExDLL/exdll.dpr @@ -78,7 +78,7 @@ begin end; end; -function GetUserVariable(varnum: TVariableList): string; +function GetUserVariable(const varnum: TVariableList): string; begin if (integer(varnum) >= 0) and (integer(varnum) < integer(__INST_LAST)) then Result := g_variables + integer(varnum) * g_stringsize @@ -86,30 +86,30 @@ begin Result := ''; end; -procedure SetUserVariable(varnum: TVariableList; value: string); +procedure SetUserVariable(const varnum: TVariableList; const value: string); begin if (value <> '') and (integer(varnum) >= 0) and (integer(varnum) < integer(__INST_LAST)) then lstrcpy(g_variables + integer(varnum) * g_stringsize, PChar(value)) end; -procedure NSISDialog(text, caption: string; buttons: integer); +procedure NSISDialog(const text, caption: string; const buttons: integer); begin MessageBox(g_hwndParent, PChar(text), PChar(caption), buttons); end; -procedure ex_dll(hwndParent: HWND; string_size: integer; variables: PChar; stacktop: pointer); cdecl; +procedure ex_dll(const hwndParent: HWND; const string_size: integer; const variables: PChar; const stacktop: pointer); cdecl; begin - // set up global variables + // setup global variables g_stringsize := string_size; g_hwndParent := hwndParent; - g_stringsize := string_size; g_stacktop := stacktop; g_variables := variables; + // end global variable setup NSISDialog(GetUserVariable(INST_0), 'The value of $0', MB_OK); NSISDialog(PopString, 'pop', MB_OK); PushString('Hello, this is a push'); - SetUserVariable(INST_0, 'This is 0'); + SetUserVariable(INST_0, 'This is user var $0'); end; exports ex_dll; diff --git a/Contrib/ExDLL/exdll_with_unit.dpr b/Contrib/ExDLL/exdll_with_unit.dpr index 6071536e..ad206af8 100644 --- a/Contrib/ExDLL/exdll_with_unit.dpr +++ b/Contrib/ExDLL/exdll_with_unit.dpr @@ -14,7 +14,7 @@ library exdll; uses nsis, windows; -procedure ex_dll(hwndParent: HWND; string_size: integer; variables: PChar; stacktop: pointer); cdecl; +procedure ex_dll(const hwndParent: HWND; const string_size: integer; const variables: PChar; const stacktop: pointer); cdecl; begin // set up global variables Init(hwndParent, string_size, variables, stacktop); @@ -22,7 +22,7 @@ begin NSISDialog(GetUserVariable(INST_0), 'The value of $0', MB_OK); NSISDialog(PopString, 'pop', MB_OK); PushString('Hello, this is a push'); - SetUserVariable(INST_0, 'This is 0'); + SetUserVariable(INST_0, 'This is user var $0'); end; exports ex_dll; diff --git a/Contrib/ExDLL/nsis.pas b/Contrib/ExDLL/nsis.pas index 05fe183b..be80e1bd 100644 --- a/Contrib/ExDLL/nsis.pas +++ b/Contrib/ExDLL/nsis.pas @@ -22,7 +22,7 @@ uses type VarConstants = ( - INST_0, + INST_0, // $0 INST_1, // $1 INST_2, // $2 INST_3, // $3 @@ -62,21 +62,21 @@ var g_variables: PChar; g_hwndParent: HWND; -procedure Init(hwndParent: HWND; string_size: integer; variables: PChar; stacktop: pointer); +procedure Init(const hwndParent: HWND; const string_size: integer; const variables: PChar; const stacktop: pointer); function PopString(): string; procedure PushString(const str: string=''); -function GetUserVariable(varnum: TVariableList): string; -procedure SetUserVariable(varnum: TVariableList; value: string); -procedure NSISDialog(text, caption: string; buttons: integer); +function GetUserVariable(const varnum: TVariableList): string; +procedure SetUserVariable(const varnum: TVariableList; const value: string); +procedure NSISDialog(const text, caption: string; const buttons: integer); implementation -procedure Init(hwndParent: HWND; string_size: integer; variables: PChar; stacktop: pointer); +procedure Init(const hwndParent: HWND; const string_size: integer; const variables: PChar; const stacktop: pointer); begin - g_stringsize:=string_size; - g_hwndParent:=hwndParent; - g_stacktop:=stacktop; - g_variables:=variables; + g_stringsize := string_size; + g_hwndParent := hwndParent; + g_stacktop := stacktop; + g_variables := variables; end; function PopString(): string; @@ -103,7 +103,7 @@ begin end; end; -function GetUserVariable(varnum: TVariableList): string; +function GetUserVariable(const varnum: TVariableList): string; begin if (integer(varnum) >= 0) and (integer(varnum) < integer(__INST_LAST)) then Result := g_variables + integer(varnum) * g_stringsize @@ -111,13 +111,13 @@ begin Result := ''; end; -procedure SetUserVariable(varnum: TVariableList; value: string); +procedure SetUserVariable(const varnum: TVariableList; const value: string); begin if (value <> '') and (integer(varnum) >= 0) and (integer(varnum) < integer(__INST_LAST)) then lstrcpy(g_variables + integer(varnum) * g_stringsize, PChar(value)) end; -procedure NSISDialog(text, caption: string; buttons: integer); +procedure NSISDialog(const text, caption: string; const buttons: integer); begin MessageBox(g_hwndParent, PChar(text), PChar(caption), buttons); end;