Module build failed (from ./node_modules/sass-loader/lib/loader.js): Cannot find module 'node-sass‘

1、当要在vue中使用scss的时候,需要安装node-sass组件

2、当使用npm install node-sass 命令安装失败时,可以再尝试用cnpm安装

     (1)cnpm安装命令:  npm install -g cnpm 

       (2)查看npm的镜像列表   nrm ls

  (3)使用淘宝镜像命令为 : nrm use taobao

  (4)cnpm install node-sass  #cnpm安装

3、如果上面都安装失败的话,用下面的方法步骤:

   npm cache clean -force     

   npm install -g mirror-config-china  

   npm install node-sass

 

ps:我是用第3个安装成功了

  • 38
    点赞
  • 65
    收藏
    觉得还不错? 一键收藏
  • 22
    评论
EurekaLog 7.5 (18-August-2016) 1)..Important: Installation layout was changed. All packages now have version suffix (e.g. EurekaLogCore240.bpl). No files are copied to \bin folder of IDE. Run-time package (EurekaLogCore) is copied to Windows\System32 folder. Refer to help for more info. 2)....Added: RAD Studio 10.1 Berlin support 3)....Added: IDE F1 help integration (on CHM-based IDEs only, i.e. XE8+) 4)....Added "--el_injectjcl", "--el_createjcl", and "--el_createdbg" command-line options for ecc32/emake to inject JEDI/JCL debug info, create .jdbg file, and create .dbg file (Microsoft debug format). Later is supported when map2dbg.exe tool is placed in \Bin folder of EurekaLog installation (separate download is required) 5)....Added: Exception2HRESULT in EAppDLL to simplify developing DLLs with "DLL" profile 6)....Added: Use ShellExecute option for mailto send method 7)....Added: "Mandatory e-mail only when sending" option 8)....Added: Exception line highlighting in disassember view in EurekaLog exception dialog and Viewer 9)....Added: Detection/logging Delphi objects in disassembly view 10)..Added: Support for multi-monitor info 11)..Added: Support for detection of Windows 10 updates 12)..Added: OS edition detection 13)..Added: "User" and "Session" columns to processes list, processes list is also sorted by session first 14)..Added: Support for showing current user processes only 15)..Added: Expanding environment variables for "Support URL" 16)..Fixed: Range-check error on systems with MBCS ACP 17)..Fixed: 64-bit shared memory manager may not work 18)..Fixed: Possible "Unit XYZ was compiled with a different version of ABC" when using packages 19)..Fixed: FastMM shared MM compatibility 20)..Fixed: Minor bugs in stack tracing (which usually affected stacks for leaks) 21)..Fixed: Rare deadlocks in multi-threaded applications 22)..Fixed: Taking screenshot of minimized window 23)..Fixed: NT service may not log all exceptions 24)..Fixed: SSL port number for Bugzilla 25)..Fixed: Disabling "Activate Exception Filters" option was ignored 26)..Fixed: Missing FTP proxy settings 27)..Fixed: IntraWeb support is updated up to 14.0.64 28)..Fixed: Retrieving some process paths in processes list 29)..Fixed: CPU view rendering in EurekaLog exception dialog and Viewer 30)..Fixed: Some issues in naming threads 31)..Fixed: Removed exported helper _462EE689226340EAA982C5E8307B3F9E function (replaced with mapped file) 32)..Changed: Descriptions of EurekaLog project options now list corresponding property names of TEurekaModuleOptions class. 33)..Changed: Default template of HTML/web dialog now includes call stack by default 34)..Changed: EurekaLog 7 now can be installed over EurekaLog 6 automatically, with no additional actions/tools EurekaLog 7.4 (7.4.0.0), 26-January-2016 1)....Fixed: Performance issue in DLL exports debug information provider 2)....Fixed: Range-check error in Send dialog 3)....Fixed: Possible FPU control word unexpected change 4)....Fixed: JIRA sending to project with no version info 5)....Fixed: Viewer sorting affected by local region settings 6)....Fixed: Exception filters ignore settings for restart/terminate EurekaLog 7.3 Hotfix 2 (7.3.2.0), 20-October-2015 1)....Fixed: Added workaround for codegen bug in Delphi 7 (possibly - other), bug manifests itself as wrong date-time in reports or integer overflows 2)....Fixed: Some MAPI DLLs may not be loaded correctly 3)....Fixed: Handling SEC_I_INCOMPLETE_CREDENTIALS in SSPI code (added searching client certificate) 4)....Fixed: Range-check error when closing WinAPI dialog EurekaLog 7.3 Hotfix 1 (7.3.1.0), 2-October-2015 1)....Fixed: Long startup time on terminal services servers EurekaLog 7.3 (7.3.0.0), 24-September-2015 1)....Added: RAD Studio 10 Seattle support 2)....Added: Performance counters for run-time (internal logging with --el_debug) 3)....Fixed: spawned by ecc32/emake processes now start with the same priority 4)....Fixed: ThreadID = 0 in StandardEurekaNotify 5)....Fixed: Dialog auto-close timer may reset without user input 6)....Fixed: Possible hang when quickly loading/unloading EurekaLog-enabled DLL 7)....Fixed: Possible hang in COM DLLs 8)....Fixed: Removed some unnecessary file system access on startup 9)....Fixed: Possible wrong font size in EurekaLog tools 10)..Fixed: Ignore timeouts from Shell_NotifyIcon 11)..Fixed: Possible failure to handle/process stack overflow exceptions 12)..Changed: VCL/CLX/FMX now will assign Application.OnException handler when low-level hooks are disabled EurekaLog 7.2 Hotfix 6 (7.2.6.0), 14-July-2015 1)....Added: csoCaptureDelphiExceptions option 2)....Fixed: Handling of SECBUFFER_EXTRA in SSPI code 3)....Fixed: Several crashes in sending code for very old Delphi versions 4)....Fixed: Regression (from hotfix 5) crash in some IDEs EurekaLog 7.2 Hotfix 5 (7.2.5.0), 1-July-2015 1)....Added: HKCU\Software\EurekaLab\Viewer\4.0\UI\Statuses registry key to allow status customizations in Viewer 2)....Added: "Disable hang detection under debugger" option 3)....Fixed: Wrong button caption in standalone "Steps to reproduce" dialog 4)....Fixed: Wrong passing of Boolean parameters in JSON (affects JIRA) 5)....Fixed: Wrong sorting of BugID, Count and DateTime columns in Viewer 6)....Fixed: Empty "Count" field/column is now displayed as "1" in Viewer 7)....Fixed: Generic names with "," could not be decoded in Viewer 8)....Fixed: Updated Windows 10 detection for latest builds of Windows 10 9)....Fixed: Sleep and hybernation no longer trigger false-positive "application freeze" 10)..Fixed: Wrong function codes for hooking (affects ISAPI application type) 11)..Fixed: Wrong button caption in "Steps to Reproduce" dialog 12)..Fixed: Crash when taking snapshot of some proccesses by Threads Snapshot tool 13)..Fixed: Minor improvements in leak detection EurekaLog 7.2 Hotfix 4 (7.2.4.0), 10-June-2015 1)....Added "ECC32TradeSpeedForMemory" option - defaults to 0/False, could be changed to 1 via Custom/Manual tab. This option will switch from fast-methods to slower methods, but which take less memory. Use 0 (default) for small projects, use 1 for large projects (if ecc32 runs out of memory). 2)....Added: --el_DisableDebuggerPresent command-line option for compatibility with 3rd party debuggers (AQTime, etc.) 3)....Added: AQTime auto-detect 4)....Fixed: Performance optimizations 5)....Fixed: Windows 8+ App Menu shortcuts 6)....Fixed: Unmangling on x64 EurekaLog 7.2 Hotfix 3 (7.2.3.0), 20-May-2015 1)....Added: Support for token auth in Bugzilla (latest 4.x builds) 2)....Added: Support for API key auth in Bugzilla (5.x) 3)....Added: Support for /EL_DisableMemoryFilter command-line option 4)....Added: Asking e-mail when user switches to "details" from MS Classic without entering e-mail 5)....Fixed: Compatibility issues with older Bugzilla versions (3.x) 6)....Fixed: Passing settings between dialogs 7)....Fixed: "Ask for steps to reproduce" dialog is now DPI-aware 8)....Fixed: Silently ignore and fix invalid values in project options EurekaLog 7.2 Hotfix 2 (7.2.2.0), 30-April-2015 1)....Fixed: Confusing message in Manage tool when using with Trial/Pro 2)....Fixed: Range check error in processes information for x64 machines (affects startup of any EurekaLog-enabled module) 3)....Fixed: Auto-detect personality by project extension if --el_mode switch is missing 4)....Fixed: More details for diagnostic sending 5)....Fixed: Wrong settings for MAP files in C++ Builder 6)....Fixed: Wrong code page was used to decode ANSI bug reports 7)....Fixed: Attaching .PAS files instead of .OBJ in C++ Builder 2006+ Pro/Trial EurekaLog 7.2 Hotfix 1 (7.2.1.0), 3-April-2015 1)....Fixed: Wrong float-str convertion when ThousandSeparator is '.' EurekaLog 7.2 (7.2.0.0), 1-April-2015 1)....Important: TEurekaLogV7 component was renamed to TEurekaLogEvents. Please, update your projects by renaming or recreating the component 2)....Important: File layout was changed for BDS 2006+. Delphi and C++ Builder files are now located in StudioNum folders instead of old DelphiNum and CBuilderNum folders. Update your search paths if needed 3)....Added: Major improvements in DumpAllocationsToFile function (EMemLeaks unit) 4)....Added: MemLeaksSetParentBlock, MemLeaksOwn, EurekaTryGetMem functions (EMemLeaks unit) 5)....Added: Improvements for call stack of dynarrays/strings allocations (leaks) 6)....Added: "Elem size" when reporting leaks in dynarrays 7)....Added: Streaming unpacked debug info into temporal files instead of memory - this greatly reduces run-time application memory usage at cost of slightly slower exception processing. This also reduces memory footprint for ecc32/emake 8)....Added: Showing call stacks for 2 new types of fatal memory errors 9)....Added: EMemLeaks._ReserveOutOfMemory to control reserve size of out of memory errors (default is 50 Mb) 10)..Added: "MinLeaksLimitObjs" option (EMemLeaks unit) 11)..Added: Fatal memory problem now pauses all threads in application 12)..Added: Fatal memory problem now change thread name (to simplify debugging) 13)..Added: boPauseELThreads and boDoNotPauseELServiceThread options (currently not visible in UI) 14)..Added: Support for texts collections out of default path 15)..Added: Support for relative file paths to text collections and external settings 16)..Added: Support for environment variables in project option's paths 17)..Added: Support for relative file paths and environment variables for events and various module paths 18)..Added: Logging in Manage tool 19)..Added: Windows 10 version detection 20)..Added: Stack overflow tracing 21)..Added: Major improvements in removal of recursive areas from call stack 22)..Added: Statistics collection 23)..Added: Support for uploading multiple files in JIRA 24)..Added: EResLeaks improvements (new funcs: ResourceAdd, ResourceDelete, ResourceName; support for realloc-like functions) 25)..Fixed: Added workaround for bug in JIRA 5.x 26)..Fixed: Rare EurekaLog internal error 27)..Fixed: Ignored unhandled thread exceptions (when EurekaLog is disabled) now triggers default OS processing (WER) 28)..Fixed: Irnored exceptions (via per-exception/events) now bring up default RTL handler 29)..Fixed: Format error in Viewer 30)..Fixed: Leak of EurekaLog exception information object 31)..Fixed: Wrong chaining exceptions inside GetMem/FreeMem 32)..Fixed: Memory leak after low-level unhook of function 33)..Fixed: Re-parenting after ReallocMem 34)..Fixed: Editing SMTP server options 35)..Fixed: SMTP server not using real user e-mail in FROM field 36)..Fixed: Some multi-threading crashes 37)..Fixed: Fixed crashes in Manage tool 38)..Fixed: Range-check error in Viewer 39)..Fixed: EurekaLog error dialog appearing under other windows 40)..Fixed: AV when parsing TDS (emake/C++ Builder specific) 41)..Fixed: Unable to build call stacks for other threads due to insufficient rights 42)..Fixed: Version checks for BugZilla and JIRA 43)..Fixed: Not catching out-of-module AVs when "Capture exceptions only from current module" option is checked 44)..Fixed: Checking for remaining exceptions at shutdown (C++ Builder specific, AcquireExceptionObject returns wrong info) 45)..Fixed: "get call stack of ... threads" / "suspend ... threads" options (avoid rare multithreading race conditions) 46)..Fixed: Crash when naming thread without EurekaLog thread info 47)..Fixed: Detection of immediate caller for memory funcs 48)..Fixed: Non-working Assign for options 49)..Fixed: Handling of explicitly chained exceptions 50)..Fixed: Various exception/threading fixes for MS debug provider 51)..Fixed: Processing hardware unhandled exceptions (QC #55007) 52)..Fixed: Unchecking dialog options when export/import 53)..Fixed: BSTR leak 54)..Fixed: JIRA decimal separator bug 55)..Changed: Now unhandled exceptions will be handled by EurekaLog even if EurekaLog is disabled in the thread - only global EurekaLog-enabled status is respected 56)..Changed: Viewer version now matches version of EurekaLog 57)..Changed: DeleteServiceFilesOption now always False by default 58)..Changed: Speed improvements for known memory leaks (reserved leaks) 59)..Changed: Improved logging for sending 60)..Changed: Switching to detailed mode without entering (mandatory) e-mail: now EL will not block this 61)..Changed: .ToString for exception info now uses compact stack formatter 62)..Removed: Custom field editor (replaced it with link to "Custom" page) 63)..Removed: EurekaLog 7 no longer could be installed over EurekaLog 6. Manage tool from EurekaLog 7 will no longer work with EurekaLog 6. EurekaLog 7.1 update 1 (7.1.1.0), 19-October-2014 1)....Added: "Send in separated thread" option 2)....Added: Hang detection will now use Wait Chain Traversal (WCT) on Vista+ systems to detect deadlocks in any EurekaLog-enabled threads 3)....Added: OS install language and UI language fields in bug report 4)....Fixed: Viewer is not able to decrypt reports with generics 5)....Fixed: EVariantTypeCastError in Viewer when changing status of some bug reports 6)....Fixed: EcxInvalidDataControllerOperation in Viewer 7)....Fixed: Stack overflow at run-time for certain combination of project options 8)....Fixed: BMP re-draw bug in UI dialogs 9)....Fixed: Rogue "corrupted" error message for valid ZIPs of certain structure 10)..Fixed: Various range check errors in Viewer 11)..Fixed: Possible encoding errors for non-ASCII reports in Viewer on certain environments 12)..Fixed: Wrong count in Viewer when importing reports without proper "count" field 13)..Fixed: Duplicate reports may appear in bug report file when "Do not save duplicate errors" option is checked 14)..Fixed: False-positive detection of some virtual machines 15)..Fixed: Processing of exceptions from message handlers during message pumping cycle inside exception dialogs 16)..Fixed: Access Violation if exception dialog was terminated by exception 17)..Fixed: Hardware exceptions from unit's initialization/finalization may be unprocessed 18)..Changed: "VIEW" action for Viewer now will open ALL bug reports inside bug report file; reports will not be merged by BugID. "IMPORT" action remains the same: duplicate reports are merged, "count" is increased 19)..Changed: Charset field in bug report now shows both charset and code page EurekaLog 7.1 (7.1.0.00), 23-September-2014 1)....Added: XE7 support 2)....Added: XE6 support 3)....Added: New DLL demo 4)....Added: Custom profiles are now shown in "Application type" combo-box 5)....Added: Non-empty "steps to reproduce" will be added to existing bug tracker issues with empty "steps to reproduce" 6)....Added: Support for custom fields in FogBugz (API version 8 and above) 7)....Added: Support for unsequenced line numbers in PDB/DBG files (--el_source switch) 8)....Fixed: XML bug report were generated wrong 9)....Fixed: Strip relocations code for Win64 10)..Fixed: EurekaLog conditional symbols removed improperly when deactivating EurekaLog 11)..Fixed: Sending reports to non-default port numbers (affects web-based methods) 12)..Fixed: SSL validation check may reject valid SSL certificate (SMTP Client/Server) 13)..Fixed: SSL errors may be not reported 14)..Fixed: Viewer did not consider empty bug reports as corrupted 15)..Fixed: "DLL" profile now can be used with packages properly 16)..Fixed: Few rare memory leaks 17)..Fixed: Possible deadlock when using MS debug info provider 18)..Fixed: C++ Builder project files was saved incorrectly (RAD Studio 2007+) 19)..Fixed: "Show restart checkbox after N errors" counts handled exceptions 20)..Fixed: IDE expert's DPR parser (added support for multi-part idents) 21)..Fixed: Rare access violation in hook code 22)..Fixed: Thread handle leaks (added _NotifyThreadGone/_CleanupFinishedThreads functions to be called manually - only when low-level hooks are not installed) 23)..Fixed: EurekaLog's installer hang 24)..Fixed: Bug in object/class validation 25)..Fixed: Bug when using TThreadEx without EurekaLog 26)..Fixed: Leaks detection may not work with certain combination of options 27)..Fixed: Deadlock in some cases when using EurekaLog threading option set to "enabled in RTL threads, disabled in Windows threads". 28)..Changed: TEurekaExceptionInfo.CallStack will be nil until exception is actually raised 29)..Changed: FogBugz and BugZilla: changed bugs identification within project (to allow two bugs exists with same BugID in different projects) 30)..Changed: Blocked manual creation/destruction of ExceptionManager class and EurekaExceptionInfo 31)..Changed: ECC32/EMAKE runs from IDE without changing priority, added ECC32PriorityClass option 32)..Improved: Minor help and text improvements EurekaLog 7.0.07 Hotfix 2 (7.0.7.2), 11-December-2013 1)....Fixed: Delphi compiler code generation bug (Delphi 2007 and below) 2)....Fixed: Code hooks may rarely be set incorrectly (code stub relocation fails) 3)....Fixed: Win64 call stacks functions now work more similar to 32 bit call stacks EurekaLog 7.0.07 Hotfix 1 (7.0.7.1), 2-December-2013 1)....Added: Alternative caption for e-mail input control when e-mail is mandatory 2)....Fixed: Rare range check error in WinAPI visual dialogs 3)....Fixed: Wrong error detection for OnExceptionError event 4)....Fixed: Wrong TResponce processing 5)....Fixed: Problems with encrypted call stack decoding 6)....Fixed: OnPasswordRequest event may have no effect EurekaLog 7.0.07 (7.0.7.0), 25-November-2013 1)....Added: Ability to use Assign between call stack and TStrings 2)....Added: 64-bit disassembler 3)....Added: Support for variables and relative file paths in "Additional Files" send option 4)....Added: --el_source switch for ecc32/emake compilers 5)....Added: support for post-processing non-Embarcadero executables 6)....Added: EOTL.pas unit for better OmniThreadLibrary integration 7)....Added: RAD Studio XE5 support 8)....Added: New "Capture call stacks of EurekaLog-enabled threads" option 9)....Added: "Deferred call stacks" option for 64-bit 10)..Added: Copy report to clipboard now copies both report text and report file 11)..Added: "AttachBothXMLAndELReports" option to include both .elx and .el files into bug report 12)..Added: EMemLeaks.MemLeaksErrorsToIgnore option to exclude certain memory errors from being considered as fatal 13)..Added: Call stack with any encrypted entry will be fully encrypted now 14)..Added: Option to exclude certain memory errors from being considered as fatal (EMemLeaks.MemLeaksErrorsToIgnore) 15)..Added: New "HTTP Error Code" option for all web-based dialogs (CGI, ISAPI, etc.) 16)..Added: Support for Unicode in Simple MAPI send method (requires Windows 8 or latest Microsoft Office) 17)..Added: New value for call stack detalization option (show any addresses, including those not belonging to any executable module) 18)..Fixed: Wrong JSON escaping for strings (affects JIRA send method) 19)..Fixed: Range-check error in Viewer when viewing bug reports with high addresses 20)..Fixed: Selecting Win32 service application type is no longer resets to custom/unsupported 21)..Fixed: Possible hang when testing dialogs from EurekaLog project options dialog 22)..Fixed: Rare resetting of some options when saving .eof file 23)..Fixed: Exception pointer could be removed from call stack due to debug details filtering 24)..Fixed: Rare case when LastThreadException returned nil while there was active thread exception 25)..Fixed: Rare case when ShowLastThreadException do nothing 26)..Fixed: Improved compatibility for OmniThreadLibrary and AsyncCalls 27)..Fixed: Included fix for QC #72147 28)..Fixed: 64-bit MS Debug Info Provider (please, re-setup cache options using configuration dialog) 29)..Fixed: "Deferred call stacks" option failed to capture call stack when exception is re-raised between threads 30)..Fixed: "Deferred call stacks" option may produce cutted call stack in rare cases 31)..Fixed: Several minor call stacks improvements and optimizations 32)..Fixed: Several 64-bit Pointer Integer convertion issues 33)..Fixed: Multi-threading deadlock issue 34)..Fixed: Black screenshots in 64 bit applications 35)..Fixed: Copying to clipboard hot-key was registered globally 36)..Fixed: Shell (mailto) send method may fail (64 bit) 37)..Fixed: Possible wrong file paths for attaches in (S)MAPI send methods 38)..Fixed: Environment variables were not expanded in MAPI send method 39)..Fixed: (non-Unicode IDE) EurekaLog is not activated when application started from folder with Unicode characters 40)..Fixed: Encrypted call stacks may be encrypted partially by EurekaLog Viewer in rare cases 41)..Fixed: Crash when sending leak report with visual progress dialog (only some IDEs are affected) 42)..Fixed: ecc32/emake could not see external configuration file with the same name as project (e.g. Project1.eof for Project1.dpr) 43)..Fixed: Added missed RTL implementation for ExternalProps in Delphi 6 (affects Mantis sending) 44)..Fixed: IDE crash when switching to threads window 45)..Changed: Removed temporal solution which was used before option to defer call stack creation was introduced 46)..Changed: "Default EurekaLog state in new threads" option is changed from Boolean flag into enum. You need to re-setup this option 47)..Changed: Disable EurekaLog for thread when creating call stack or handle exception - this increases stability and performance 48)..Changed: LastException property is remove from exception manager as not thread safe. Use LastThreadException property instead 49)..Changed: Lock/Unlock from thread manager and exception manager are removed to avoid deadlocks 50)..Changed: ThreadsSnapshot tool now tries to capture call stack without injecting DLL 51)..Changed: Build events now runs with CREATE_NO_WINDOW flag (console window is hidden) 52)..Improved: More articles in help EurekaLog 7.0.06 (7.0.6.0), 1-June-2013 1)....Added: Experimental 64 bit C++ Builder support 2)....Added: New tab in EurekaLog project options: "External tools" 3)....Added: Option to catch all IDE errors (to debug your own IDE packages) 4)....Added: Option to catch only exceptions from current module 5)....Added: Option to defer building call stack 6)....Added: RAD Studio XE4 support 7)....Added: Support for AppWave 8)....Fixed: Fixed event handlers declarations for the EurekaLog component 9)....Fixed: Infinite recursive calls when using ToString from EndReport event handler 10)..Fixed: UPX compatibility issue 11)..Fixed: Range check errors for system error codes 12)..Fixed: Rare IDE stack overflow 13)..Fixed: JIRA unit was not added automatically 14)..Fixed: EurekaLog no longer tries to check for leaks when memory manager filter is disabled 15)..Fixed: Possible deadlock on shutdown with freeze checks active 16)..Fixed: Issues with settings dialog and Win32 Service application type 17)..Fixed: ThreadSnapshot tool was not able to take snapshots of Win64 processes 18)..Fixed: WCT is disabled for leaks 19)..Fixed: TContext declarations for Win64 20)..Fixed: Check for updates now correctly sets time of last check 21)..Fixed: (Win64) Several Pointer Integer convertion errors 22)..Fixed: Internal error when exception info object was deleted while it was still used by SysUtils exception object 23)..Fixed: Semeral problems with "EurekaLog look & feel" style for EurekaLog error dialog 24)..Fixed: Using text collection resets exception filters 25)..Fixed: Rare access violation if registering event handlers is placed too early 26)..Fixed: SMTP RFC date formatting 27)..Fixed: Rare empty call stack bug 28)..Fixed: Hang detection was not working if EurekaLog was disabled in threads 29)..Fixed: AV for double-free TEncoding 30)..Changed: ecc32/emake no longer alters arguments for dcc32/make unless new options --el_add_default_options is specified 31)..Changed: Save/load options methods was moved to TEurekaModuleOptions class 32)..Changed: Saving options to EOF file now adds hidden options and removes obsolete options (only when compatibility mode is off) 33)..Changed: Compiling installed packages now silently ignores EurekaLog instead of showing "File is in use" error message 34)..Improved: More readable disk/memory sizes in bug reports 35)..Improved: More descriptive settings dialog when using external configuration 36)..Improved: ThreadSnapshot tool now aquired DEBUG priviledge for taking snapshot. This allows it to bypass security access checks when opening target process. 37)..Improved: Changed BugID default generation to include error code for OS errors and error message for DB errors 38)..Improved: Mantis API (WSDL) was updated to the latest version (1.2.14) 39)..Improved: IntraWeb compatibility (old and new versions) 40)..Improved: COM applications compatibility 41)..Improved: Build events now accept shell commands 42)..Improved: More articles in help EurekaLog 7.0.05 (7.0.5.0), 7-February-2013 1)....Added: JIRA support 2)....Added: Virtual machine detection (new field in bug reports) 3)....Fixed: "Use Main Module options" option was loading empty options for some cases 4)....Fixed: Wrong record declarations for Simple MAPI on Win64 5)....Fixed: Performance issues with batch module options updating 6)....Fixed: Wrong leaks report with both MemLeaks/ResLeaks options active 7)....Fixed: Wrong info for nested exceptions in some cases 8)....Fixed: AV under debugger for Win64 (added support for _TExitDllException) 9)....Fixed: Wrong record declarations for process/thread info on Win64 10)..Fixed: Support for FinalBuilder on XE2/XE3 with spaces in file paths 11)..Fixed: Rare double-free of module information (ModuleInfoList) 12)..Fixed: Rare External Exception C000071C on shutdown (only under debuggger) 13)..Fixed: Added large addresses support in Viewer 14)..Fixed: Counter options in memory leaks category is now working properly 15)..Fixed: Rare range-check error in TEurekaModulesList.AddModuleFromFileName 16)..Fixed: FTP force directories dead lock 17)..Fixed: Fixed wrong index being used when clearing compatibility mode (EurekaLog project options dialog) 18)..Fixed: Default thread state do not affect main thread now 19)..Fixed: Sometimes wrong thread may be used when altering EurekaLog active state for external thread 20)..Fixed: Wrong DNS lookup on ANSI 21)..Fixed: Problems with IDE expert and projects on network paths 22)..Fixed: Added support for arguments in URLs (HTTP sending) 23)..Fixed: Possible deadlock in multithreaded applications 24)..Fixed: Problems with unicode characters in project files on non-Unicode IDEs 25)..Fixed: Infinite recursive calls when using ToString from EndReport event handler 26)..Fixed: Win64 GetCaller now returns pointer to call instruction, not return address 27)..Improved: Standalone Editor do not force save/load folder by default 28)..Improved: DLL profile now can use additional application type hooks automatically 29)..Improved: EurekaLog now able to work with read-only projects (see help for more info) EurekaLog 7.0.04 (7.0.4.0), 2-December-2012 1)....Added: Support for nested exceptions in DLLs 2)....Fixed: Options bug in EurekaLogSendEmail function 3)....Fixed: Weird behaviour for steps to reproduce and custom fields 4)....Fixed: Installation for single personality (BDS) 5)....Fixed: Range check error in EModules 6)....Fixed: Bug in exception destroy hook 7)....Fixed: OnExceptionNotify event is no longer called for handled exceptions without option checked 8)....Fixed: DEP checks on startup no longer cause exception 9)....Fixed: Invalid declaration for MS Debug API 10)..Fixed: OLE mode change error for "Test" send button 11)..Fixed: Fixes for multiply loading of the same DLL 12)..Fixed: Removed PNG compression from icons (tools) 13)..Fixed: Range-check error in dialogs with EurekaLog style enabled 14)..Fixed: Send progress dialog may keep busy forever processing window messages (message flood from rapid application GUI updates) 15)..Fixed: Thread pausing options now work correctly 16)..Improved: New features in exception filters - marking exceptions as "expected", filtering by properties (RTTI) 17)..Improved: Recovery from memory errors without debugging memory manager 18)..Improved: Viewer's password edit now hides password with asterisks 19)..Updated: Changed names of .inc files to avoid name conflicts with other libraries 20)..Updated: Help EurekaLog 7.0.03 (7.0.3.0), 6-October-2012 1)....Fixed: Removed some consts keywords for event handlers, so now C++ Builder can alter arguments (this change may require you to adjust your custom code) 2)....Fixed: Fallback code for false-positive results on memory probing 3)....Fixed: Range check errors in SSL/TLS implementation 4)....Fixed: "EurekaLog is not active" error message during send testing 5)....Fixed: Incorrect memory probing when DEP is off (old systems) 6)....Fixed: Installation of 64-bit BPLs 7)....Fixed: Dialog preview 8)....Fixed: Win64 fixes for XE3 9)....Fixed: Support for project groups (mixed project types) 10)..Fixed: Windows 2000 hooks compatibility 11)..Fixed: mailto double quotes escaping 12)..Fixed: Simple MAPI WOW compatibility 13)..Fixed: Simple MAPI modal issues 14)..Fixed: Various range check errors 15)..Changed: Removed minor version number from program group name 16)..Updated: Help EurekaLog 7.0.02 hot-fix 1 (7.0.2.1), 12-September-2012 1)....Fixed: Range check error in Viewer 2)....Fixed: Bug in hooking code EurekaLog 7.0.02 (7.0.2.0), 11-September-2012 1)....Added: Improved memory problems detection 2)....Added: Minor IDE Expert usability improvements 3)....Added: Auto-size feature for detailed error dialog 4)....Added: Workaround for QC #106935 5)....Added: Workaround for bug in InvokeRegistry (SOAP/Mantis) 6)....Fixed: Nested OS exceptions 7)....Fixed: Multiply Win64 fixes 8)....Fixed: Compatibility mode fixes 9)....Fixed: Altered behaviour of "Add BugID/Date/ComputerName" options 10)..Fixed: Blank screenshots 11)..Fixed: Check file for corruptions 12)..Fixed: Viewer is unable to decrypt certain bug reports 13)..Fixed: Internal DoNoTouch option now works for post-processing and condtionals 14)..Fixed: Possible out of memory error for "Do not store class/procedure names" option 15)..Fixed: EurekaLog did not properly install itself when there is only Delphi installed, but no C++ Builder of the same version (or visa versa) 16)..Fixed: Wrong argument for OnRaise event 17)..Fixed: Handling memory errors in initialization/finalization sections 18)..Fixed: Updating steps to reproduce and user e-mail in bug report 19)..Fixed: Proper Success/Failure for some errors during SMTP send 20)..Added: Workaround for wrong GUI fonts 21)..Added: Delphi XE3 support 22)..Added: Individual options for each exception EurekaLog 7.0.01 (7.0.1.0), 28-June-2012 1)....Added: New "Modal window" option (MS Classic and EurekaLog dialogs) 2)....Added: New "Owned window" option (MS Classic and EurekaLog dialogs) 3)....Added: New "Catch EurekaLog IDE Expert errors" option 4)....Added: Backup memory manager to recover from critical errors 5)....Added: Alternative methods to provide additional features when memory filter is not set 6)....Fixed: Contains fixes from hotfixes 1-3 7)....Fixed: Performance improvements 8)....Fixed: Improved IDE Expert's speed, stability and compatibility with other 3rd party extensions 9)....Fixed: MS Classic dialog size adjustments for large "click here" translations 10)..Fixed: Fixed resetting few EurekaLog project options to defaults 11)..Fixed: Multiplying exception filters when options are assigned (for example: when switching to/from "Custom" page in project options) 12)..Fixed: (Compatibility mode) Fixed send options merging 13)..Fixed: Updated help EurekaLog 7.0 hot-fix 3 (7.0.0.273), 20-June-2012 --------------------------- 1)....Fixed: ERangeError in EResLeaks (THandle Integer) 2)....Fixed: C++ Builder breakpoints for large projects 3)....Fixed: Help (updates policy changed) 4)....Fixed: Text collections applying 5)....Fixed: Build events are now called for unlocked file 6)....Fixed: Proper handling of C++ Builder project options files from Delphi code (settings editor and IDE expert) 7)....Fixed: Terminate/Checked sub-option for MS Classic dialog 8)....Fixed: Confusing message for already post-processed executables 9)....Fixed: Access violation for some EurekaLog IDE menu items when no project was loaded 10)..Fixed: Invoking help for "Variables" window 11)..Fixed: EurekaLog Viewer version info 12)..Fixed: Events in components 13)..Added: Retry option for "Sorry, you must close all running IDE instances before installation" 14)..Added: Italian translation 15)..Added: Actual change log is now included into installer 16)..Added: Even more setup logging 17)..Added: New help articles (recompilation and manual installation) EurekaLog 7.0 hot-fix 2 (7.0.0.261), 10-June-2012 --------------------------- 1)....Fixed: Wrong version info reporting to IDE 2)....Added: Workaround for Delphi 2005 TListView bug 3)....Added: Workaround for possible invalid FPU state in exception handlers 4)....Added: Missed declarations for ExceptionLog (compatibility mode) 5)....Fixed: Work for unsaved projects 6)....Added: Escaping for '--' in options (confuses IDE's XML parsing) 7)....Added: Storing thread's class/name in call stack for terminated threads 8)....Added: More setup logging 9)....Fixed: Help (broken links) 10)..Added: "Upgrade to EurekaLog 7" help topic 11)..Fixed: Clean up installed files EurekaLog 7.0 hot-fix 1 (7.0.0.256), 6-June-2012 --------------------------- 1)....Fixed: Invalid Format() arguments in ELogBuilder. EurekaLog 7.0, 1-June-2012 --------------------------- 1)....Improved: Main change - EurekaLog's core was rewritten (refactored) to allow more easy modification and remove hacks. 2)....Improved: New plugin-like architecture now allows you to exclude unused code. 3)....Improved: New plugin-like architecture now allows you to easily extends EurekaLog. 4)....Improved: Greatly extended documentation. 5)....Improved: Installer is now localized. 6)....Improved: Greatly speed ups creation of minimal bug report (with most information disabled). 7)....Changed: EurekaLog's root IDE menu was relocated to under Tools and extended with new items. 8)....Added: New examples. 9)....Added: New tools (address lookup, error lookup, threads snapshot, standalone settings editor). 10)..Added: Support for DBG/PDB formats of debug information (including symbol server support and auto-downloading). 11)..Added: Support for madExcept debug information (experimental). 12)..Added: WER (Windows Error Reporting) support. 13)..Added: Full unicode support. 14)..Added: Professional and Trial editions: added source code (interface sections only) 15)..Improved: Dialogs - new options and new customization possibilities: 16)..Added: All GUI dialogs: ability to test dialog directly from configuration dialog by displaying a sample window with currently specified settings. 17)..Improved: All GUI dialogs: dialogs are DPI-awared now (auto-scale for different DPI). 18)..Added: MessageBox dialog: added detailed mode (shows a compact call stack). 19)..Added: MessageBox dialog: added ability for asking a send consent. 20)..Added: MessageBox dialog: added support to switch to "native" message box for application. 21)..Added: MS Classic dialog: added control over "user e-mail" edit's visibility. 22)..Added: MS Classic dialog: added ability to personalize dialog view with application's name and icon. 23)..Added: MS Classic dialog: added ability to show terminate/restart checkbox initially checked. 24)..Added: EurekaLog dialog: added ability to personalize dialog view with application's name and icon. 25)..Added: EurekaLog dialog: added ability to show terminate/restart checkbox initially checked. 26)..Added: EurekaLog dialog: added ability to switch back to non-detailed view. 27)..Added: WEB dialog: added new tags to customize bug report page. 28)..Improved: WEB dialog: improved support for unicode and charset. 29)..Added: New dialog type: RTL dialog. 30)..Added: New dialog type: console output. 31)..Added: New dialog type: system logging. 32)..Added: New dialog type: Windows Error Reporting. 33)..Improved: Sending - new options and new customization possibilities: 34)..Added: All send methods: added ability to setup multiply send methods. 35)..Added: All send methods: added ability to change send method order. 36)..Added: All send methods: added separate settings for each send method. 37)..Added: All send methods: ability to test send method directly from configuration dialog by sending a demo bug report. 38)..Added: SMTP client send method: added SSL support. 39)..Added: SMTP client send method: added TLS support. 40)..Added: SMTP client send method: added option for using real e-mail address. 41)..Added: SMTP server send method: added option for using real e-mail address. 42)..Added: HTTP upload send method: added support for custom backward feedback messages. 43)..Added: FTP upload send method: added creating folders on FTP (like remote ForceDirectories). 44)..Added: Mantis send method: added API support (MantisConnect, out-of-the-box since Mantis 1.1.0, available as add-on for previous versions). 45)..Added: Mantis send method: added support for custom "Count" field. 46)..Added: Mantis send method: added options for controlling duplicates. 47)..Added: Mantis send method: added support for SSL/TLS. 48)..Added: FogBugz send method: added API support (out-of-the-box since ForBugz 7, available as add-on for FogBugz 6). 49)..Added: FogBugz send method: EurekaLog will update "Occurrences" field (count of bugs). 50)..Added: FogBugz send method: EurekaLog will respect "Stop reporting" option (BugzScout's setting). 51)..Added: FogBugz send method: EurekaLog will respect "Scout message" option (BugzScout's setting). 52)..Added: FogBugz send method: EurekaLog will store client's e-mail as issue's correspondent. 53)..Added: FogBugz send method: added options for controlling duplicates. 54)..Added: FogBugz send method: added support for "Area" field. 55)..Added: FogBugz send method: added support for SSL/TLS. 56)..Added: BugZilla send method: added API support. 57)..Added: BugZilla send method: added support for custom "Count" field. 58)..Added: BugZilla send method: added options for controlling duplicates. 59)..Added: BugZilla send method: added support for SSL/TLS. 60)..Added: New send method: Shell (mailto protocol). 61)..Added: New send method: extended MAPI. 62)..Added: Support for separate code and debug info injection. 63)..Added: Ability to use custom units before EurekaLog's units. 64)..Added: Support for external configuration file in IDE expert. 65)..Added: Now EurekaLog stores only those project options which are different from defaults (to save disk space and reduce noise in project file). 66)..Added: Now EurekaLog stores project options sorted (alphabet order). 67)..Added: Separate settings for saving modules and processes lists to bug report. 68)..Added: Support for taking screenshots of multiply monitors. 69)..Added: More screenshot customization options. 70)..Added: More control over bug report's file names. 71)..Added: New environment variables. 72)..Added: Deleting .map file after compilation. 73)..Added: Support for different .dpr and .dproj file names. 74)..Improved: memory leaks detection feature - new options and new customization possibilities: 75)..Added: Ability to track memory problems without activation of leaks checking. 76)..Added: Support for sharing memory manager. 77)..Added: Support for tracking leaks in applications built with run-time packages. 78)..Added: Option to zero-fill freed memory. 79)..Added: Option to enable leaks detection only when running under debugger. 80)..Added: Option for manual activation control for leaks detection (via command-line switches). 81)..Added: Option to select stack tracing method for memory problems. 82)..Added: Option to trigger memory leak reporting only for large leaked memory's size. 83)..Added: Option to control limit of number of reported leak. 84)..Added: CheckHeap function to force check of heap's consistency. 85)..Added: DumpAllocationsToFile function to save information about allocated memory to log file. 86)..Added: Registered leaks feature. 87)..Added: Run-time control over memory leak registering. 88)..Added: New recognized leak type: String (both ANSI and Unicode are supported). 89)..Added: Memory features support for C++ Builder. 90)..Added: Resource leaks detection feature. 91)..Improved: Compilation speed increased. 92)..Added: Support for generics in debug information. 93)..Added: Chained/nested exceptions support. 94)..Added: Wait Chain Traversal support. 95)..Added: Support for named threads. 96)..Added: Additional information for threads in call stack. 97)..Improved: EurekaLog Viewer Tool: 98)..Added: Now Viewer has its own help file 99)..Added: Viewer now supports a FireBird based database on local file or remote server. 100).Added: You can have more that one user account for FireBird based database. 101).Added: Viewer now can be launched in View mode (Viewer can be configured to any DB or View mode). 102).Added: Viewer's database now supports storing files, associated with the report (you can also add and remove files manually). 103).Added: Viewer supports "Import" and "View" commands for report files. 104).Improved: Extended support for more log formats (XML, packed ELF, etc). 105).Added: Columns in report's list now can be configured (you can hide and show them). 106).Added: There are a plenty of new columns added to report's list. 107).Added: Ability of auto-download reports from e-mail account. 108).Improved: printing - now you can print the entire report (including screenshots). Old behaviour of printing just one tab (call stack only, for example) also remains. 109).Added: Viewer can now have more that one run-time instance . 110).Added: File import status dialog is now configurable (you can disable it, if you want to). 111).Added: There is a preview area for screenshots, available in reports. 112).Improved: Now Viewer is more Vista-friendly (i.e. file associations are managed in HKCU, rather that in HKLM, storing configuration in user's Application Data, etc, etc). 113).Added: Report's list now supports multi-select, so operations can be performed on many reports at time. 114).Added: There are plenty of new command line abilities, like specifying several files and new switches. 115).Improved: Bunch of minor changes and improvements. WARNING: -------- There are many changes in this release. See the "Changed from the old 6.x version" help topic for further information! EurekaLog 7 also have "EurekaLog 6 backward compatibility mode". Please, refer to help file for more information. We also have the detailed "Upgrade guide" in our help system.
全志R16平台编译linux系统V1.0.txt 2017/4/11 13:36 (编译请使用编译android的lichee的选项编译生成的.config文件,不然直接编译会报错!!!!) rootroot@cm-System-Product-Name:/home/wwt/linux_r16$ tar zxvf lichee_parrotv1.1_20161202.tar.gz rootroot@cm-System-Product-Name:/home/wwt/linux_r16$ cd lichee/ rootroot@cm-System-Product-Name:/home/wwt/linux_r16/lichee$ ./build.sh config Welcome to mkscript setup progress All available chips: 0. sun8iw5p1 Choice: 0 All available platforms: 0. android 1. dragonboard 2. linux 3. tina Choice: 2 All available kernel: 0. linux-3.4 Choice: 0 All available boards: 0. bell-one 1. evb 2. evb-20 3. evb-30 4. evb-rtl8723bs 5. sc3813r Choice: 3 rootroot@cm-System-Product-Name:/home/wwt/linux_r16/lichee$ ./build.sh 错误1: KCONFIG_AUTOCONFIG=/home/wwt/linux_r16/lichee/out/sun8iw5p1/linux/common/buildroot/build/buildroot-config/auto.conf KCONFIG_AUTOHEADER=/home/wwt/linux_r16/lichee/out/sun8iw5p1/linux/common/buildroot/build/buildroot-config/autoconf.h KCONFIG_TRISTATE=/home/wwt/linux_r16/lichee/out/sun8iw5p1/linux/common/buildroot/build/buildroot-config/tristate.config BUILDROOT_CONFIG=/home/wwt/linux_r16/lichee/out/sun8iw5p1/linux/common/buildroot/.config /home/wwt/linux_r16/lichee/out/sun8iw5p1/linux/common/buildroot/build/buildroot-config/conf --silentoldconfig Config.in # # make dependencies written to .auto.deps # ATTENTION buildroot devels! # See top of this file before playing with this auto-preprequisites! # make[1]:正在离开目录 `/home/wwt/linux_r16/lichee/buildroot' You must install 'makeinfo' on your build machine makeinfo is usually part of the texinfo package in your distribution make: *** [dependencies] 错误 1 make:离开目录“/home/wwt/linux_r16/lichee/buildroot” ERROR: build buildroot Failed rootroot@cm-System-Product-Name:/home/wwt/linux_r16/lichee$ d/buildroot-config/conf.o /home/wwt/linux_r16/lichee/out/sun8iw5p1/linux/common/buildroot/build/buildroot-config/zconf.tab.o -o /home/wwt/linux_r16/lichee/out/sun8iw5p1/linux/common/buil
1 介绍 LuaBind 是一个帮助你绑定C++和Lua的库.她有能力暴露 C++ 函数和类到 Lua . 她也有 能力支持函数式的定义一个Lua类,而且使之继承自C++或者Lua. Lua类可以覆写从 C++ 基类 继承来的虚函数. 她的目标平台是Lua 5.0 ,不能支持Lua 4.0 . 她利用模板原编程技术实现.这意味着,你不需要额外的预处理过程去编译你的工程(编译器 会替你完成全部的工作).这还意味着,你也不需要(通常)知道你注册的每一个函数的精确的签名. 因为,LuaBind库会在编译时生成所需的代码.这样做的不利点是,编译时间会随着需要注册的 文件的数目增加而增加.因此建议你把所有的需要注册的东西放到一个cpp文件里面. LuaBind 遵循 MIT 协议 发布. 我们非常希望听说有工程使用了LuaBind, 请告诉我们,如果你的工程使用了LuaBind. 主要的反馈渠道是 LuaBind邮件列表 .在 irc.freenode.net还可以找到一个IRC频道 #luabind . 2 功能 LuaBind支持: * 重载自由函数 * C++类导入Lua * 重载成员函数 * 操作符 * 属性 * 枚举 * Lua函数导入C++ * Lua类导入C++ * Lua类(单继承) * 从Lua或C++类继承 * 覆写C++类的虚函数 * 注册类型间隐式的类型转换 * 最好匹配式签名匹配 * 返回值策略和参数策略 3 可移植性 LuaBind 已经通过下面的编译器环境的测试: Visual Studio 7.1 Visual Studio 7.0 Visual Studio 6.0 (sp 5) Intel C++ 6.0 (Windows) GCC 2.95.3 (cygwin) GCC 3.0.4 (Debian/Linux) GCC 3.1 (SunOS 5.8) GCC 3.2 (cygwin) GCC 3.3.1 (cygwin) GCC 3.3 (Apple, MacOS X) GCC 4.0 (Apple, MacOS X) LuaBind被确认不能在 GCC 2.95.2 (SunOS 5.8) 下工作. Metrowerks 8.3 (Windows) 可以编译LuaBind,但是通不过常量测试.这就意味着常量 成员函数被视同非常量成员函数. 如果你测试了LuaBind和其他未列出的编译器的兼容性,请告诉我们你的结果. 4 构建LuaBind 为了抑制LuaBind的编译时间最好是将其编译为一个库. 这意味着你要不编译并连接LuaBind 库要不就添加其所有源码到你的工程里面.你必须确保LuaBind目录在你的编译器包含目录中. LuaBind需要Boost 1.32.0 或者 1.33.0 (只需要头文件即可). LuaBind还需要Lua. 官方的构建LuaBind的方式是通过 Boost.Build V2 . 为此,你需要设置两个环境变量: BOOST_ROOT 指向你的Boost安装目录 LUA_PATH 指向你的Lua目录.编译系统将假定包含文件和库文件分别放在 $(LUA_PATH)/include/ 和 $(LUA_PATH)/lib/. 为了向后兼容性,LuaBind在根目录下还保留了一个makefile.这可以构建库和测试程序.如果 你正在使用一个UNIX系统(或者 cygwin),他们将使得构建LuaBind静态库变得很简单.如果 你正在使用 Visual Studio ,很简单的包含 src 目录下的文件到你的工程即可. 构建LuaBind的时候,你可以设定一些选项来使得库更加符合你的需求.特别重要的是,你的应用 程序也必须使用和库一样的设定.可用的选项的介绍参见 Build options 章节. 如果你希望改变缺省的设置,推荐你通过修改命令行参数的方式来实现.(在Visual Studio 的工程设置项里面). 5 基本使用 为了使用LuaBind, 你必须包含 lua.h 和 LuaBind 的主要头文件: extern "C" { #include "lua.h" } #include <luabind/luabind.hpp> 这些头文件提供了注册函数和类的功能. 如果你只是想获得函数或者类的支持,你可以分开 包含 luabind/function.hpp 和 luabind/class.hpp: #include <luabind/function.hpp> #include <luabind/class.hpp> 你需要去做的第一件事是 调用 luabind::open(lua_State*), 由此注册可以在Lua创建类 的函数并初始化 LuaBind需要使用的 状态机全局结构. 如果你不调用这个函数, 你会在后面 触发一个 断言 . 不没有一个对应的关闭函数.因为,一旦一个类被注册到Lua,真没有什么好 的方法去移除它.部分原因是任何剩余的类实例都将依赖其类. 当状态机被关闭的时候,所有 的一切都将被清理干净. LuaBind 的头文件不会直接包含 Lua.h , 而是透过 <luabind/lua_include.hpp> . 如果你 出于某种原因需要包含其他的Lua头文件,你可以修改此文件. 5.1 Hello World 新建一个控制台DLL工程, 名字是 luabind_test. #include <iostream> #include <luabind/luabind.hpp> #include <luabind/lua_include.hpp> extern "C" { #include "lua.h" #include "lauxlib.h" } void greet() { std::cout << "hello world!\n"; } extern "C" int luaopen_luabind_test(lua_State* L) { using namespace luabind; open(L); module(L) [ def("greet", &greet) ]; return 0; } 把生成的DLL和lua.exe/lua51.dll放在同一个目录下. Lua 5.1.2 Copyright (C) 1994-2007 Lua.org, PUC-Rio > require "luabind_test" > greet() Hello world! > 6 作用域 注册到Lua里面的所有东西要不注册于一个名空间下(Lua table)要不注册于全局作用域(lua module). 所有注册的东西必须放在一个作用域里面.为了定义一个模块, luabind::module 类必须被使用. 使用方式如下: module(L) [ // declarations ]; 这将会注册所有的函数或者类到 Lua 全局作用域. 如果你想要为你的模块设定一个名空间(类似标准模块), 你可以给构造函数设定一个名字,例如: module(L, "my_library") [ // declarations ]; 这里所有的申明都将被放置在 my_libary 表. 如果你想要嵌套名空间,你可以用 luabind::namespace_ 类. 它和 luabind::module 类似,除了构造器 没有lua_State* 输入参数.用例如下: module(L, "my_library") [ // declarations namespace_("detail") [ // library-private declarations ] ]; 你可能会想到,下面两个声明是等价的: module(L) [ namespace_("my_library") [ // declarations ] ]; module(L, "my_library") [ // declarations ]; 每一个声明必须用逗号分隔,例如: module(L) [ def("f", &f), def("g", &g), class_<A>("A") .def(constructor<int, int>), def("h", &h) ]; 更多实际的例子请参阅 绑定函数到Lua 和 绑定类到Lua 章节. 请注意, (如果你对性能有很高的需求)把你的函数放到表里面将增加查找函数的时间. 7 绑定函数到Lua 为了绑定函数到Lua,你可以使用函数 luabind::def(). 它的声明如下: template<class F, class policies> void def(const char* name, F f, const Policies&); * name 是该函数在Lua里面的名字 * F 是该函数的指针 * 策略参数是用来描述怎样处理该函数参数和返回值的.这是一个可选参数,参见 策略 章节. 下面的例子演示注册函数 float std::sin(float): module(L) [ def("sin", &std::sin) ]; 7.1 重载函数 如果你有同名函数需要注册到Lua, 你必须显示的给定函数的签名. 这可以让C++知道你指定的是哪一个函数. 例如, 如果你有两个函数, int f(const char*) 和 void f(int). module(L) [ def("f", (int(*)(const char*)) &f), def("f", (void(*)(int)) &f) ]; 7.2 签名匹配 LuaBind 将会生成代码来检查Lua栈的内容是否匹配你的函数的签名. 它会隐式的在 派生类之间进行类型转换,并且它会按照尽量少进行隐式类型转换的原则经行匹配.在 一个函数调用中,如果函数是重载过的,并且重载函数的参数匹配分不出好坏的话 (都经行同样次数的隐式类型转换),那么将产生一个二义性错误.这将生成一个运行时 错误,程序挂起在产生二义性调用的地方.一个简单的例子是,注册两个函数,一个函数 接受一个int参数,另外一个函数接受一个float参数. 因为Lua将不区别浮点数和整形数, 所以他们都是匹配的. 因为所有的重载是被测试过的,这将总是找到最好的匹配(不是第一个匹配).这样意味着, LuaBind可以处理签名的区别只是const和非const的重载函数. 例如,如果如下的函数和类被注册: struct A { void f(); void f() const; }; const A* create_a();所有权转移 为了正确处理所有权转移问题,create_a()将用来适配返回值策略. 参见 策略 章节. -Linker Lin 4/5/08 6:32 PM struct B: A {}; struct C: B {}; void g(A*); void g(B*); 执行以下 Lua 代码即结果: a1 = create_a() a1:f() -- 常量版本被调用 a2 = A() a2:f() -- 非常量版本被调用 a = A() b = B() c = C() g(a) -- calls g(A*) g(b) -- calls g(B*) g(c) -- calls g(B*) 7.3 调用Lua函数 为了调用一个Lua函数, 你可以或者用 call_function() 或者用 一个对象(object). template<class Ret> Ret call_function(lua_State* L, const char* name, ...) template<class Ret> Ret call_function(object const& obj, ...) call_function()函数有两个重载版本.一个是根据函数的名字来调用函数, 另一个是调用一个可以作为函数调用的Lua值. 使用函数名来调用的版本只能调用Lua全局函数. "..."代表传递给Lua函数的 可变个数的参数. 这使得你可以指定调用的策略.你可以通过 operator[] 来实现 这个功鞥.你可以同过方括号来指定策略,例如: int ret = call_function<int>( L , "a_lua_function" , new complex_class() )[ adopt(_1) ]; 如果你想通过引用方式传递参数,你必须用Boost.Ref来包装一下. 例如: int ret = call_function(L, "fun", boost::ref(val)); 如果你想给一个函数调用指定自己的错误捕获处理函数(error handler),可以参阅 pcall errorfunc 章节的 set_pcall_callback . 7.4 使用Lua协程 为了使用Lua协程,你必须调用 lua_resume(),这就意味着你不能用先前介绍的函数 call_function()来开始一个协程.你必须用这个: template<class Ret> Ret resume_function(lua_State* L, const char* name, ...) template<class Ret> Ret resume_function(object const& obj, ...) 和: template<class Ret> Ret resume(lua_State* L, ...) 第一次开始一个协程的时候,你必须给它一个入口函数. 当一个协程返回(yield)的时候, resume_fucntion()调用的返回值是 lua_yield()的第一个传入参数.当你想要继续一个 协程的时候,你只需要调用 resume() 在你的 lua_State() 上,因为它已经在执行一个函数 (即先前出入的入口函数),所以你不需要再次传入函数.resume()的传入参数将作为Lua侧的 yield()调用的返回值. 为了暂停(yielding)C++函数,(不支持在C++侧和Lua侧传送数据块),你可以使用 yield 策略. 接受 object 参数的resume_function()的重载版本要求对象必须是一个协程对象.(thread) lua_State* thread = lua_newthread(L); object fun = get_global(thread)["my_thread_fun"]; resume_function(fun); 8 绑定类到Lua 为了注册一个类,你可以用 class_ 类. 它的名字和C++关键字类似是为了比较直观.它有一个重载 过的成员函数 def() .这个函数被用来注册类的成员函数,操作符,构造器,枚举和属性.它将返回 this 指针,从而方便你直接注册更多的成员. 让我们开始一个简单的例子.考虑下面的C++类: class testclass { public: testclass(const std::string& s): m_string(s) {} void print_string() { std::cout << m_string << "\n"; } private: std::string m_string; }; 为了注册这个类到Lua环境,可以像下面这样写(假设你使用了名空间): module(L) [ class_<testclass>("testclass") .def(constructor<const std::string&>()) .def("print_string", &testclass::print_string) ]; 这将注册 testclass 类以及接受一个string参数的构造器以及一个成员叫print_string()的函数. Lua 5.0 Copyright (C) 1994-2003 Tecgraf, PUC-Rio > a = testclass('a string') > a:print_string() a string 还可以注册自由函数作为成员函数.对这个自由函数的要求是,它必须接受该类的一个指针或常量指针或 引用或常量引用作为函数的第一个参数.该函数的剩下的参数将在Lua侧可见,而对象指针将被赋值给第一个 参数.如果我们有如下的C++代码: struct A { int a; }; int plus(A* o, int v) { return o->a + v; } 你可以注册 plus() 作为A的一个成员函数,如下: class_<A>("A") .def("plus", &plus) plus() 现在能够被作为A的一个接受一个int参数的成员函数来调用.如果对象指针(this指针)是const, 这个函数也将表现的像一个常量成员函数那样(它可以通过常量对象来调用). 8.1 重载成员函数 当绑定超过一个以上的重载过的成员函数的时候,或只是绑定其中的一个的时候,你必须消除你传递给 def() 的 成员函数指针的歧义.为此,你可以用普通C风格的类型转换来转型匹配正确的重载函数. 为此,你必须知道怎么去 描述C++成员函数的类型.这里有一个简短的教程(更多信息请查阅你的C++参考书): 成员函数指着的语法如下: return-value (class-name::*)(arg1-type, arg2-type, ...) 例如: struct A { void f(int); void f(int, int); }; class_<A>() .def("f", (void(A::*)(int))&A::f) A的第一个成员函数f(int)被绑定了,而第二个没哟被绑定. 8.2 属性 很容易注册类的全局数据成员.考虑如下的类: struct A { int a; }; 这个类可以这样注册: module(L) [ class_<A>("A") .def_readwrite("a", &A::a) ]; 这使得成员变量 A::a 获得了读写访问权. 还可以注册一个只读的属性: module(L) [ class_<A>("A") .def_readonly("a", &A::a) ]; 当绑定成员是一个非原始数据类型的时候,自动生成的 getter 函数将会返回一个它引用. 这就允许你可以链式使用 . 操作符.例如,当有一个结构体包含另外一个结构体的时候.如下: struct A { int m; }; struct B { A a; }; 当绑定B到Lua的时候,下面的表达式应该可以工作: b = B() b.a.m = 1 assert(b.a.m == 1) 这要求 a 属性必须返回一个A的引用, 而不是一个拷贝. 这样,LuaBind将会自动使用依赖策略来 确保返回值依赖于它所在的对象.所以,如果返回的引用的生命长于该对象的所有的引用(这里是b). 它将保持对象是激活的,从而避免出现悬挂指针. 你还可以注册 getter 或者 setter 函数来使得它们看上去像一个 public 的成员.考虑下面的类: class A { public: void set_a(int x) { a = x; } int get_a() const { return a; } private: int a; }; 可以这样注册成一个公共数据成员: class_<A>("A") .property("a", &A::get_a, &A::set_a) 这样 set_a() 和 get_a() 将取代简单的数据成员操作.如果你想使之只读,你只需要省略最后一个参数. 请注意, get 函数必须是 const 的,否则不能通过编译. 8.3 枚举 如果你的类包含枚举,你可以注册它们到Lua. 注意,它们不是类型安全的,所有的枚举在Lua侧都是整型的, 并且所有接受枚举参数的函数都将接受任何整型.你可以像这样注册它们: module(L) [ class_<A>("A") .enum_("constants") [ value("my_enum", 4), value("my_2nd_enum", 7), value("another_enum", 6) ] ]; 在Lua侧,他们可以像数据成员那样被操作,除了它们是只读的而且属于类本身而不是类的实例. Lua 5.0 Copyright (C) 1994-2003 Tecgraf, PUC-Rio > print(A.my_enum) 4 > print(A.another_enum) 6 8.4 操作符 为了绑定操作符,你需要包含头文件 <luabind/operator.hpp>. 注册你的类的操作符的机制非常的简单.你通过一个全局名字 luabind::self 来引用类自己,然后你就 可以在def()调用里面直接用操作符表达式. 类如下: struct vec { vec operator+(int s); }; 可以这样注册: module(L) [ class_<vec>("vec") .def(self + int()) ]; 不管你的 + 操作符是定义在类里面还是自由函数都可以工作. 如果你的操作符是常量的(const)(或者,是一个自由函数, 接受一个类的常量的引用)你必须用 const_self 替代 self. 如下: module(L) [ class_<vec>("vec") .def(const_self + int()) ]; 支持如下操作符: + - * / == < <= 这意味着,没有"就地操作符"(in-place)(++ --). 相等操作符(==)有些敏锐;如果引用是相等的就不会 被调用. 这意味着, 相等操作符的效率非常好. Lua不支持操作符包括: !=,>和<=.这是为什么你只能注册上面那些操作符. 当你调用这些操作符的时候, Lua会把调用转换到支持的操作符上.(译注:例如:==和!=有逻辑非得关系) -Linker Lin 4/6/08 11:09 PM 在上面的示例中,操作数的类型是 int().如果操作数的类型是复杂类型,就不是那么简单了,你需要用 other<> 来包装下.例如: 为了注册如下的类,我们不想用一个string的实例来注册这个操作符. struct vec { vec operator+(std::string); }; 取而代之的是,我们用 other<> 包装下,如下: module(L) [ class_<vec>("vec") .def(self + other<std::string>()) ]; 注册一个应用程序操作符(函数调用): module(L) [ class_<vec>("vec") .def( self(int()) ) ]; 这里有个特殊的操作符.在Lua里,它叫做 __tostring,它不是一个真正的操作符.它是被用来转换一个对象到 string的标准Lua方法.如果你注册之,可以通过Lua的标准函数 tostring() 来转换你的对象到一个string. 为了在C++里实现这个操作符,你需要为 std::ostream 提供 operator<< .像这样: class number {}; std::ostream& operator<<(std::ostream&, number&); ... module(L) [ class_<number>("number") .def(tostring(self)) ]; 8.5 嵌套作用域和静态函数 可以添加嵌套的作用域到一个类.当你需要包装一个嵌套类或者一个静态函数的时候就会很有用. class_<foo>("foo") .def(constructor<>() .scope [ class_<inner>("nested"), def("f", &f) ]; 在上面的例子里, f 将表现的像一个类 foo 的静态函数,而 类 nested 将表现的像类 foo 的嵌套类. 还可以用同样的语法添加名空间到类里面. 8.6 继承类 如果你想要注册一个继承自其它类的类到Lua, 你可以指定一个模板参数 bases<> 给 class_ 的构造器. 如下的继承关系: struct A {}; struct B : A {}; 可以这样注册: module(L) [ class_<A>("A"), class_<B, A>("B") ]; 如果你使用了多继承,你可以指定多于一个的基类.如果 B 还继承了类 C , 它可以这样注册: module(L) [ class_<B, bases<A, C> >("B") ]; 注意,你可以省去 bases<> 当你用的是单继承的时候. 注意 如果你不指定类的继承关系, LuaBind 将不能在相关的继承类型间进行隐式类型转换. 8.7 智能指针 当你注册一个类的时候,你可以告诉 LuaBind 所有的该类的实例应该被某种智能指针持有.(例如: boost::shared_ptr) 你可通过把一个 持有器类型模板参数 给 class_ 类的构造器来实现该功能.例如: module(L) [ class_<A, boost::shared_ptr<A> >("A") ]; 你还必须为你的智能指针提供两个函数.一个返回常量版本的智能指针类型(这里是: boost:shared_ptr< const A >). 另一个函数要可以从智能指针萃取流指针(raw pointer). 之所以需要第一个函数是因为,LuaBind 允许 非常量 -> 转换在传递Lua值到C++的时候.之所以需要第二个函数是因为,当Lua调用一个被智能指针持有 的类的成员函数的时候,this 指针必须是一个流指针.还有一个原因是,从Lua转换到C++的时候,需要实现 智能指针到普通指针的转换.看上去像这样: namespace luabind { template<class T> T* get_pointer(boost::shared_ptr<T>& p) { return p.get(); } template<class A> boost::shared_ptr<const A>* get_const_holder(boost::shared_ptr<A>*) { return 0; } } 第二个函数只在编译时用于映射 boost::shared_ptr<A>到其常量版本 boost::shared_ptr<const A>. 它从来不会被调用,所以返回值是无所谓的(返回值的类型才是关键). 这个转换将这样工作(假定 B 是A的基类): 从Lua到C++ Source Target holder_type<A> A* holder_type<A> B* holder_type<A> A const* holder_type<A> B const* holder_type<A> holder_type<A> holder_type<A> holder_type<A const> holder_type<A const> A const* holder_type<A const> B const* holder_type<A const> holder_type<A const 从C++到Lua Source Target holder_type<A> holder_type<A> holder_type<A const> holder_type<A const> holder_type<A> const& holder_type<A> holder_type<A const> const& holder_type<A const> 当使用持有器类型的时候,知道指针是不是合法(例如:非空)是很有用的.例如,当使用 std::auto_ptr 的时候, 持有器通过一个参数传递给函数的时候将会变得无效. 为了这个目的,所有的对象实例都有一个成员叫: __ok. struct X {}; void f(std::auto_ptr<X>); module(L) [ class_<X, std::auto_ptr<X> >("X") .def(constructor<>()), def("f", &f) ]; Lua 5.0 Copyright (C) 1994-2003 Tecgraf, PUC-Rio > a = X() > f(a) > print a.__ok false 当注册一个继承树的时候,所有的实例被智能指针持有的地方,所有的类必须包含持有器类型.例如: module(L) [ class_<base, boost::shared_ptr<base> >("base") .def(constructor<>()), class_<derived, base, boost::shared_ptr<base> >("base") .def(constructor<>()) ]; 在内部, LuaBind 将会做必要的转换于萃取自持有器的流指针之上. 8.8 拆分类注册 在某些情况下,可能需要分开注册一个类在不同的编译单元. 部分原因可能是节约重编译时间,而某些编译器的 限制可能要求不得不分开注册一个类.其实很简单.考虑下面的示例代码: void register_part1(class_<X>& x) { x.def(/*...*/); } void register_part2(class_<X>& x) { x.def(/*...*/); } void register_(lua_State* L) { class_<X> x("x"); register_part1(x); register_part2(x); module(L) [ x ]; } 这里,类X被分两步注册.两个函数 register_part 和 register_part2 可能被放到不同的编译单元里. 关于分开注册一个模块的信息请参阅: 分开注册 章节. 9 对象 因为函数必须能够接受Lua值作为参数,我们必须包装之. 这个包装被称作 luabind::object. 如果你注册的函数 接受一个对象,那它就可以匹配任何Lua值.为了使用它,你需要包含头文件: <luabind/object.hpp>. 摘要 class object { public: template<class T> object(lua_State*, T const& value); object(from_stack const&); object(object const&); object(); ~object(); lua_State* interpreter() const; void push() const; bool is_valid() const; operator safe_bool_type () const; template<class Key> implementation-defined operator[](Key const&); template<class T> object& operator=(T const&); object& operator=(object const&); bool operator==(object const&) const; bool operator<(object const&) const; bool operator<=(object const&) const; bool operator>(object const&) const; bool operator>=(object const&) const; bool operator!=(object const&) const; template <class T> implementation-defined operator[](T const& key) const void swap(object&); implementation-defined operator()(); template<class A0> implementation-defined operator()(A0 const& a0); template<class A0, class A1> implementation-defined operator()(A0 const& a0, A1 const& a1); /* ... */ }; 当你需要一个Lua对象的时候,你可以通过=操作符给它赋一个新值.当你这么做的时候,default_policy 会被用来转换C++值到Lua. 如果你的 luabind::object 是一个table,你可以通过 []操作符或者迭代器 来访问它的成员.[]操作符的返回值是一个代理对象,这个对象可以用于读写表里的值(通过=操作符). 注意,没有办法知道一个Lua对象是否可以索引化访问( lua_gettable 不会失败,要不成功,要不崩溃 ). 这意味着,如果你在一个不可以索引化访问的东西上进行索引,你就只能靠自己了.Lua将会调用它的 panic() 函数. 还有一些自由函数可以用来索引一张table,参阅 相关函数 章节. 那个接受 from_stack 对象作为参数的构造器是用来初始化一个关联Lua栈值的对象的. from_stack 类型 有如下的构造器: from_stack(lua_State* L, int index); index参数就是原始的Lua栈的索引,负值是从栈顶开始索引的.你可以这样用: object o(from_stack(L, -1)); 这将会创建一个 object的实例 o,并拷贝Lua栈顶的对象的值. interpreter() 函数返回保存object实例的Lua状态机.如果你想要直接用Lua函数操作object对象的实例,你 可以通过调用 push() 来把它压入Lua栈. ==操作符将会在操作数上调用 lua_equal()并返回它的结果. is_valid() 函数会告诉你object的实例是否已经初始化过了.通过默认构造器来初始化的实例是非法的.要使之 合法,你可以给其赋一个值.如果你想使一个 object 不合法,最简单的办法就是给它赋一个非法的 object. operator safe_bool_type() 和 to is_valid() 是等价的.这意味着,下面的代码片段是等价的: object o; // ... if (o) { // ... } ... object o; // ... if (o.is_valid()) { // ... } 应用程序操作符() 将会像对待一个函数那样来调用绑定的值. 你可以给它任何数量的参数 (目前, default_policy 将被用于转换 ).返回的对象将代表函数的返回值(当前只支持一个返回值).该操作符 可能会抛出 luabind::error ,如果函数调用失败.如果你想指定一个特殊的函数调用策略,你可以通过在函数 调用时使用 []操作符来指定策略.像这样: my_function_object( 2 , 8 , new my_complex_structure(6) ) [ adopt(_3) ]; 这告诉 LuaBind 让 Lua 接受所有权和负责传入给lua函数的指针. 重要的是当Lua状态机关闭的时候,所有的 object 的实例都会被析构.object实例会持有Lua状态机的指针,并在 自己析构的时候释放它的Lua对象. 这里有一个函数怎样使用 table 的例子: void my_function(object const& table) { if (type(table) == LUA_TTABLE) { table["time"] = std::clock(); table["name"] = std::rand() < 500 ? "unusual" : "usual"; std::cout << object_cast<std::string>(table[5]) << "\n"; } } 如果函数接受一个object作为参数,那么任何Lua值都将匹配这个参数.这就是为什么,我们必须保证入参是一个table 的原因. std::ostream& operator<<(std::ostream&, object const&); 流操作符可以把object实例借由 boost::lexical_cast 转换到string或者方便打印输出.这将会使用Lua的string 转换函数.如果你用 tostring 去转换一个C++对象,对应类型的流操作符将会被使用. 9.1 迭代器 有两种迭代器. 普通迭代器将会使用对象的原方法(如果存在)来获取值. 普通迭代器被称为 luabind::iterator. 另一个 迭代器被称为 luabind::raw_iterator ,它将忽略原方法而直接给出表里的真实内容. 它们具有相同的接口, 都实现了 ForwardIterator 概念.大部分标准迭代器都有如下的成员和构造器: class iterator { iterator(); iterator(object const&); object key() const; standard iterator members }; 接受一个 luabind::object 的构造器实际上是一个用于操作 object 的模板.通过传入一个 object 给构造器来构造出 一个指向 object 里的第一个元素的迭代器. 缺省的构造器将会初始化迭代器为一个指向最后一个元素的后面位置的迭代器.这可以用来测试是否抵达了序列的末端. 迭代器的值类型是一个支持和 luabind::object 相同的操作的代理类型.这意味着,大部分情况下你可以当它就是一个原始 的 object 实例. 它们之间的不同之处在于,任何对代理的赋值操作都会导致值被插入到表中迭代器所指的位置. key() 成员返回迭代器用于索引表的键. 一个迭代器的例子如下: for (iterator i(globals(L)["a"]), end; i != end; ++i) { *i = 1; } end 迭代器是一个缺省的指向序列末尾的迭代器.在这个例子里,我们简单的迭代了表 a 里面所有的实体,并将之赋值为 1. 9.2 相关函数 这里介绍些用于 对象 和 表 操作的函数. int type(object const&); 这个函数将会返回lua类型索引.例如: . LUA_TNIL, LUA_TNUMBER 等. template<class T, class K> void settable(object const& o, K const& key, T const& value); template<class K> object gettable(object const& o, K const& key); template<class T, class K> void rawset(object const& o, K const& key, T const& value); template<class K> object rawget(object const& o, K const& key); 这些函数是用来索引 table 用的. settable 和 gettable 函数分别翻译调用到 lua_settable 和 lua_gettable 函数. 这意味着,你可以在对象上使用索引操作符. rawset 和 rawget 将会翻译调用到 lua_rawset 和 lua_rawget. 所以他们可以绕开任何原方法而给你表里实体的 真实值. template<class T> T object_cast<T>(object const&); template<class T, class Policies> T object_cast<T>(object const&, Policies); template<class T> boost::optional<T> object_cast_nothrow<T>(object const&); template<class T, class Policies> boost::optional<T> object_cast_nothrow<T>(object const&, Policies); object_cast 函数转型对象的值到C++值.你可以给这个从lua到C++的转换提供一个转换策略.如果转型失败, cast_failed 异常将被抛出. 如果你已经定义了 LUABIND_NO_ERROR_CHECKING (参阅 编译选项)宏,就不会 进行任何检查,如果转型非法,应用程序将会彻底崩溃. 不抛出异常的版本会返回一个没有初始化的 boost::optional<T> 对象,由此来指出转型不能进行. 上面的函数的签名确实是模板化的 object 参数,但是这里你应该只传递 object 对象. object globals(lua_State*); object registry(lua_State*); 这些函数分别返回全局环境表和Lua注册表. object newtable(lua_State*); 这个函数创建一个新的 table 并以一个 object 来返回它. 10 在Lua里定义类 作为一个附加功能,LuaBind还提供了一个 Lua侧OO系统来绑定C++函数和对象. class 'lua_testclass' function lua_testclass:__init(name)-- 译注:这个风格类似Python的OO语法 self.name = name end function lua_testclass:print() print(self.name) end a = lua_testclass('example') a:print() 在Lua类之间可以使用继承: class 'derived' (lua_testclass) function derived:__init() super('derived name') end function derived:print() print('Derived:print() -> ') lua_testclass.print(self)-- 译注:注意这里 : 和 . 的区别 end 这里的 super 关键字用来初始化基类.用户必须在构造器里面第一个调用 super. 正如你在这个例子里看到的,你可以调用基类的成员函数.你可以找到所有的基类成员,但是你必须把 this指针(self) 做为函数的第一个参数. 10.1 在Lua里继承 你还可以从Lua侧继承一个C++类,并用Lua函数来覆写虚函数.为了实现这个,我们必须为C++基类创建一个封装类. 当我们实例化一个Lua类的时候,这个封装类将持有Lua对象. class base { public: base(const char* s) { std::cout << s << "\n"; } virtual void f(int a) { std::cout << "f(" << a << ")\n"; } }; struct base_wrapper : base, luabind::wrap_base { base_wrapper(const char* s) : base(s) {} virtual void f(int a) { call<void>("f", a); } static void default_f(base* ptr, int a) { return ptr->base::f(a); } }; ... module(L) [ class_<base, base_wrapper>("base") .def(constructor<const char*>()) .def("f", &base::f, &base_wrapper::default_f) ]; 重要 因为MSVC6.5不支持成员函数的显示模板参数化,作为成员函数 call()的替代, 你可以调用自由函数 call_member()并把 this指针作为第一个参数传入该函数. 注意,如果你同时绑定 base 类 和 base类封装,你必须把基类和基类的封装一起作为模板参数提供给 class_ (就像上面的例子中所做的一样).你指定它们的顺序并不重要.你必须还要从wrapper注册静态版本的和虚函数版 本的封装函数,这是让LuaBind实现动态和静态分派函数调用的必须. 重要 极其重要的是静态(缺省)函数的签名必须和虚函数一致.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 22
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值