aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--cppcheck.suppress3
-rw-r--r--doc/ScintillaDoc.html9
-rw-r--r--doc/ScintillaHistory.html5
-rw-r--r--scripts/HeaderOrder.txt1
-rw-r--r--win32/SciLexer.vcxproj1
-rw-r--r--win32/ScintillaDLL.cxx35
-rw-r--r--win32/ScintillaWin.cxx34
-rw-r--r--win32/ScintillaWin.h15
-rw-r--r--win32/deps.mak1
-rw-r--r--win32/makefile21
-rw-r--r--win32/scintilla.mak49
11 files changed, 83 insertions, 91 deletions
diff --git a/cppcheck.suppress b/cppcheck.suppress
index 35b25eac5..edaaa7d36 100644
--- a/cppcheck.suppress
+++ b/cppcheck.suppress
@@ -15,9 +15,6 @@ unusedFunction:scintilla/qt/ScintillaEdit/ScintillaDocument.cpp
// code legibility.
passedByValue
-// The three private methods DefWndProc, ScrollText, and ModifyScrollBars are called by superclasses
-unusedPrivateFunction:scintilla/win32/ScintillaWin.cxx
-
// Suppress most lexer warnings since the lexers are maintained by others
redundantCondition:scintilla/lexers/LexA68k.cxx
useInitializationList:scintilla/lexers/LexAsm.cxx
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html
index 8ba5d668b..dcd61adb3 100644
--- a/doc/ScintillaDoc.html
+++ b/doc/ScintillaDoc.html
@@ -8298,12 +8298,11 @@ EM_SETTARGETDEVICE
<p>On Windows, Scintilla is normally used as a dynamic library as a .DLL file. If you want to
link Scintilla directly into your application .EXE or .DLL file, then you can link to the static library
- bin/libscintilla.lib (or .a if using GCC) and call <code>Scintilla_RegisterClasses</code>. Otherwise, if using an IDE or other build system, then the
- <code>STATIC_BUILD</code> preprocessor symbol should be defined and
- <code>Scintilla_RegisterClasses</code> called. <code>STATIC_BUILD</code> prevents compiling the
- <code>DllMain</code> function which will conflict with any <code>DllMain</code> defined in your
- code. <code>Scintilla_RegisterClasses</code> takes the <code>HINSTANCE</code> of your
+ bin/libscintilla.lib (or .a if using GCC) and call <code>Scintilla_RegisterClasses</code>.
+ <code>Scintilla_RegisterClasses</code> takes the <code>HINSTANCE</code> of your
application and ensures that the "Scintilla" window class is registered.</p>
+ <p>When producing a stand-alone Scintilla DLL, the ScintillaDLL.cxx file should be compiled and
+ linked in to provide <code>DllMain</code> and <code>Scintilla_RegisterClasses</code>.</p>
<h3>Ensuring lexers are linked into Scintilla</h3>
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html
index 222b29a2e..5e89dd1cb 100644
--- a/doc/ScintillaHistory.html
+++ b/doc/ScintillaHistory.html
@@ -543,7 +543,10 @@
</li>
<li>
On Win32, the standard makefiles build a libscintilla static library as well as the existing dynamic libraries.
- The statically linked version of SciTE, Sc1, links to this static library.
+ The statically linked version of SciTE, Sc1, links to this static library. A new file, ScintillaDLL.cxx, provides
+ the DllMain function required for a stand-alone Scintilla DLL. Build and project files should include this
+ file when producing a DLL and omit it when producing a static library or linking Scintilla statically.
+ The STATIC_BUILD preprocessor symbol is no longer used.
</li>
<li>
In some cases, invalid UTF-8 is handled in a way that is a little friendlier.
diff --git a/scripts/HeaderOrder.txt b/scripts/HeaderOrder.txt
index a28491488..d15bb5a87 100644
--- a/scripts/HeaderOrder.txt
+++ b/scripts/HeaderOrder.txt
@@ -155,6 +155,7 @@
// win32
#include "PlatWin.h"
#include "HanjaDic.h"
+#include "ScintillaWin.h"
// gtk
#include "ScintillaGTK.h"
diff --git a/win32/SciLexer.vcxproj b/win32/SciLexer.vcxproj
index 184ef86e8..91c85139b 100644
--- a/win32/SciLexer.vcxproj
+++ b/win32/SciLexer.vcxproj
@@ -118,6 +118,7 @@
<ClCompile Include="..\win32\HanjaDic.cxx" />
<ClCompile Include="..\win32\PlatWin.cxx" />
<ClCompile Include="..\win32\ScintillaWin.cxx" />
+ <ClCompile Include="..\win32\ScintillaDLL.cxx" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\include\*.h" />
diff --git a/win32/ScintillaDLL.cxx b/win32/ScintillaDLL.cxx
new file mode 100644
index 000000000..1ecf1c16e
--- /dev/null
+++ b/win32/ScintillaDLL.cxx
@@ -0,0 +1,35 @@
+// Scintilla source code edit control
+/** @file ScintillaDLL.cxx
+ ** DLL entry point for Scintilla.
+ **/
+// Copyright 1998-2018 by Neil Hodgson <neilh@scintilla.org>
+// The License.txt file describes the conditions under which this software may be distributed.
+
+#undef _WIN32_WINNT
+#define _WIN32_WINNT 0x0500
+#undef WINVER
+#define WINVER 0x0500
+#include <windows.h>
+
+#include "Scintilla.h"
+#include "ScintillaWin.h"
+
+extern "C"
+__declspec(dllexport)
+sptr_t __stdcall Scintilla_DirectFunction(
+ ScintillaWin *sci, UINT iMessage, uptr_t wParam, sptr_t lParam) {
+ return Scintilla::DirectFunction(sci, iMessage, wParam, lParam);
+}
+
+extern "C" int APIENTRY DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpvReserved) {
+ //Platform::DebugPrintf("Scintilla::DllMain %d %d\n", hInstance, dwReason);
+ if (dwReason == DLL_PROCESS_ATTACH) {
+ if (!Scintilla_RegisterClasses(hInstance))
+ return FALSE;
+ } else if (dwReason == DLL_PROCESS_DETACH) {
+ if (lpvReserved == NULL) {
+ Scintilla::ResourcesRelease(true);
+ }
+ }
+ return TRUE;
+}
diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx
index 73d8f370c..81ebdfaa8 100644
--- a/win32/ScintillaWin.cxx
+++ b/win32/ScintillaWin.cxx
@@ -90,6 +90,7 @@
#include "PlatWin.h"
#include "HanjaDic.h"
+#include "ScintillaWin.h"
#ifndef SPI_GETWHEELSCROLLLINES
#define SPI_GETWHEELSCROLLLINES 104
@@ -3383,15 +3384,15 @@ sptr_t ScintillaWin::DirectFunction(
return reinterpret_cast<ScintillaWin *>(ptr)->WndProc(iMessage, wParam, lParam);
}
-extern "C"
-#ifndef STATIC_BUILD
-__declspec(dllexport)
-#endif
-sptr_t __stdcall Scintilla_DirectFunction(
+namespace Scintilla {
+
+sptr_t DirectFunction(
ScintillaWin *sci, UINT iMessage, uptr_t wParam, sptr_t lParam) {
return sci->WndProc(iMessage, wParam, lParam);
}
+}
+
LRESULT PASCAL ScintillaWin::SWndProc(
HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam) {
//Platform::DebugPrintf("S W:%x M:%x WP:%x L:%x\n", hWnd, iMessage, wParam, lParam);
@@ -3436,28 +3437,17 @@ int Scintilla_RegisterClasses(void *hInstance) {
return result;
}
-static int ResourcesRelease(bool fromDllMain) {
+namespace Scintilla {
+
+int ResourcesRelease(bool fromDllMain) {
const bool result = ScintillaWin::Unregister();
Platform_Finalise(fromDllMain);
return result;
}
+}
+
// This function is externally visible so it can be called from container when building statically.
int Scintilla_ReleaseResources() {
- return ResourcesRelease(false);
-}
-
-#ifndef STATIC_BUILD
-extern "C" int APIENTRY DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpvReserved) {
- //Platform::DebugPrintf("Scintilla::DllMain %d %d\n", hInstance, dwReason);
- if (dwReason == DLL_PROCESS_ATTACH) {
- if (!Scintilla_RegisterClasses(hInstance))
- return FALSE;
- } else if (dwReason == DLL_PROCESS_DETACH) {
- if (lpvReserved == NULL) {
- ResourcesRelease(true);
- }
- }
- return TRUE;
+ return Scintilla::ResourcesRelease(false);
}
-#endif
diff --git a/win32/ScintillaWin.h b/win32/ScintillaWin.h
new file mode 100644
index 000000000..6d4d2ce26
--- /dev/null
+++ b/win32/ScintillaWin.h
@@ -0,0 +1,15 @@
+// Scintilla source code edit control
+/** @file ScintillaWin.h
+ ** Define functions from ScintillaWin.cxx that can be called from ScintillaDLL.cxx.
+ **/
+// Copyright 1998-2018 by Neil Hodgson <neilh@scintilla.org>
+// The License.txt file describes the conditions under which this software may be distributed.
+
+class ScintillaWin;
+
+namespace Scintilla {
+
+int ResourcesRelease(bool fromDllMain);
+sptr_t DirectFunction(ScintillaWin *sci, UINT iMessage, uptr_t wParam, sptr_t lParam);
+
+}
diff --git a/win32/deps.mak b/win32/deps.mak
index c0839f33a..f4db4cd0f 100644
--- a/win32/deps.mak
+++ b/win32/deps.mak
@@ -2,6 +2,7 @@ CheckD2D.o: CheckD2D.cxx
HanjaDic.o: HanjaDic.cxx ../src/UniConversion.h HanjaDic.h
PlatWin.o: PlatWin.cxx ../include/Platform.h ../lexlib/StringCopy.h \
../src/XPM.h ../src/UniConversion.h ../src/DBCS.h ../src/FontQuality.h
+ScintillaDLL.o: ScintillaDLL.cxx
ScintillaWin.o: ScintillaWin.cxx ../include/Platform.h \
../include/ILoader.h ../include/Sci_Position.h ../include/ILexer.h \
../include/Scintilla.h ../lexlib/StringCopy.h ../src/Position.h \
diff --git a/win32/makefile b/win32/makefile
index 183c732b5..88014a093 100644
--- a/win32/makefile
+++ b/win32/makefile
@@ -117,7 +117,7 @@ BASEOBJS = \
XPM.o \
HanjaDic.o
-SOBJS = ScintillaWin.o ScintillaBase.o $(BASEOBJS)
+SOBJS = ScintillaDLL.o ScintillaWin.o ScintillaBase.o $(BASEOBJS)
# Required by lexers
LEXLIBOBJS=\
@@ -141,10 +141,10 @@ SCILEXOBJS=\
$(COMPONENT): $(SOBJS) Scintilla.def
$(CXX) $(LDFLAGS) -o $@ $(STRIPFLAG) $(SOBJS) $(CXXFLAGS) $(LIBS)
-$(LEXCOMPONENT): ScintillaWinL.o $(SCILEXOBJS) Scintilla.def
- $(CXX) $(LDFLAGS) -o $@ $(STRIPFLAG) ScintillaWinL.o $(SCILEXOBJS) $(CXXFLAGS) $(LIBS)
+$(LEXCOMPONENT): ScintillaDLL.o ScintillaWinL.o $(SCILEXOBJS) Scintilla.def
+ $(CXX) $(LDFLAGS) -o $@ $(STRIPFLAG) ScintillaDLL.o ScintillaWinL.o $(SCILEXOBJS) $(CXXFLAGS) $(LIBS)
-$(LIBSCI): ScintillaWinS.o $(SCILEXOBJS)
+$(LIBSCI): ScintillaWin.o $(SCILEXOBJS)
$(AR) rc $@ $^
$(RANLIB) $@
@@ -176,22 +176,9 @@ ScintillaWinL.o: ScintillaWin.cxx Platform.h \
LexerModule.h Catalogue.h CaseConvert.h \
CaseFolder.h
-ScintillaWinS.o: ScintillaWin.cxx Platform.h \
- ILexer.h Scintilla.h SplitVector.h \
- Partitioning.h RunStyles.h ContractionState.h \
- CellBuffer.h CallTip.h KeyMap.h Indicator.h \
- XPM.h LineMarker.h Style.h AutoComplete.h \
- ViewStyle.h CharClassify.h Decoration.h \
- Document.h Selection.h PositionCache.h \
- EditModel.h Editor.h EditView.h ScintillaBase.h UniConversion.h \
- CaseConvert.h CaseFolder.h
-
ScintillaBaseL.o:
$(CXX) $(CXXFLAGS) -D SCI_LEXER -c $< -o $@
-ScintillaWinS.o:
- $(CXX) $(CXXFLAGS) -D STATIC_BUILD -c $< -o $@
-
ScintillaWinL.o:
$(CXX) $(CXXFLAGS) -D SCI_LEXER -c $< -o $@
diff --git a/win32/scintilla.mak b/win32/scintilla.mak
index 91b727d4c..15de55698 100644
--- a/win32/scintilla.mak
+++ b/win32/scintilla.mak
@@ -106,7 +106,8 @@ BASEOBJS=\
SOBJS=\
$(BASEOBJS) \
$(DIR_O)\ScintillaBase.obj \
- $(DIR_O)\ScintillaWin.obj
+ $(DIR_O)\ScintillaWin.obj \
+ $(DIR_O)\ScintillaDLL.obj
#++Autogenerated -- run scripts/LexGen.py to regenerate
#**LEXOBJS=\\\n\(\t$(DIR_O)\\\*.obj \\\n\)
@@ -245,10 +246,10 @@ $(DIR_O)\ScintRes.res : ScintRes.rc
$(COMPONENT): $(SOBJS) $(DIR_O)\ScintRes.res
$(LD) $(LDFLAGS) -DEF:Scintilla.def -DLL -OUT:$@ $** $(LIBS)
-$(LEXCOMPONENT): $(SCILEXOBJS) $(DIR_O)\ScintillaWinL.obj $(DIR_O)\ScintRes.res
+$(LEXCOMPONENT): $(SCILEXOBJS) $(DIR_O)\ScintillaDLL.obj $(DIR_O)\ScintillaWinL.obj $(DIR_O)\ScintRes.res
$(LD) $(LDFLAGS) -DEF:Scintilla.def -DLL -OUT:$@ $** $(LIBS)
-$(LIBSCI): $(SCILEXOBJS) $(DIR_O)\ScintillaWinS.obj
+$(LIBSCI): $(SCILEXOBJS) $(DIR_O)\ScintillaWin.obj
LIB /OUT:$@ $**
# Define how to build all the objects and what they depend on
@@ -269,9 +270,6 @@ $(DIR_O)\ScintillaBaseL.obj: ..\src\ScintillaBase.cxx
$(DIR_O)\ScintillaWinL.obj: ScintillaWin.cxx
$(CXX) $(CXXFLAGS) -DSCI_LEXER -c $(NAME)$@ ScintillaWin.cxx
-$(DIR_O)\ScintillaWinS.obj: ScintillaWin.cxx
- $(CXX) $(CXXFLAGS) -DSTATIC_BUILD -c $(NAME)$@ ScintillaWin.cxx
-
# Dependencies
# All lexers depend on this set of headers
@@ -965,6 +963,8 @@ $(DIR_O)\ScintillaBaseL.obj: \
../src/Editor.h \
../src/AutoComplete.h \
../src/ScintillaBase.h
+$(DIR_O)\ScintillaDLL.obj: \
+ ScintillaDLL.cxx
$(DIR_O)\ScintillaWin.obj: \
ScintillaWin.cxx \
../include/Platform.h \
@@ -1039,43 +1039,6 @@ $(DIR_O)\ScintillaWinL.obj: \
../src/ScintillaBase.h \
PlatWin.h \
HanjaDic.h
-$(DIR_O)\ScintillaWinS.obj: \
- ScintillaWin.cxx \
- ../include/Platform.h \
- ../include/ILoader.h \
- ../include/Sci_Position.h \
- ../include/ILexer.h \
- ../include/Scintilla.h \
- ../lexlib/StringCopy.h \
- ../src/Position.h \
- ../src/UniqueString.h \
- ../src/SplitVector.h \
- ../src/Partitioning.h \
- ../src/RunStyles.h \
- ../src/ContractionState.h \
- ../src/CellBuffer.h \
- ../src/CallTip.h \
- ../src/KeyMap.h \
- ../src/Indicator.h \
- ../src/LineMarker.h \
- ../src/Style.h \
- ../src/ViewStyle.h \
- ../src/CharClassify.h \
- ../src/Decoration.h \
- ../src/CaseFolder.h \
- ../src/Document.h \
- ../src/CaseConvert.h \
- ../src/UniConversion.h \
- ../src/Selection.h \
- ../src/PositionCache.h \
- ../src/EditModel.h \
- ../src/MarginView.h \
- ../src/EditView.h \
- ../src/Editor.h \
- ../src/AutoComplete.h \
- ../src/ScintillaBase.h \
- PlatWin.h \
- HanjaDic.h
$(DIR_O)\Selection.obj: \
../src/Selection.cxx \
../include/Platform.h \