User forums > Using Code::Blocks
Script C::B
Jenna:
--- Quote from: LETARTARE on December 13, 2011, 03:28:06 pm ---with the two previous scripts plugin.
I just tested it with svn 7633 and it works without any errors.
--- End quote ---
I just committed the patch in svn r7639 .
LETARTARE:
--- Quote ---I just committed the patch in svn r7639 .
--- End quote ---
I care and I test svn 7639
I wrote the equivalent for svn <7588.
LETARTARE:
--- Quote from: LETARTARE on December 17, 2011, 03:04:11 pm ---
--- End quote ---
--- Quote ---I care and I test svn 7639
--- End quote ---
big thank you to 'jens' for the work done (days have 72 hours!)
My test results on r7639 :
I check 'wxArrayString ProjectFile::buildTargets' and 'ProjectFile * cbProject::GetFile(int)'
with script plugin : 'listfilesproject.script'
--- Code: ---/*******************************************************************************
* Name: listfilesproject.script
* Purpose: Script plugin in CODE::BLOCKS
* Author: LETARTARE (http://forums.codeblocks.org)
* Created: 2011-12-17
* Version 0.4.0
* Copyright: LETARTARE
* License: GPL
******************************************************************************/
/// ATTENTION
///-----------------------------------------------------------------------------
/// ** for svn r7639 ** (by 'jens')
///-----------------------------------------------------------------------------
/// ** for svn in r7588..r7639 **, 'GetFile(int)' was deleted !!!
/// patch 'reimplement_GetFile_index_20111212-1.patch' in r7639 (by 'jens')
/// this script use new methods of patch:
/// use, add ====> 'wxArrayString ProjectFile::buildTargets' <==== use
/// add => 'int ProjectBuildTarget::GetFilesCount()' <=
/// add => 'ProjectFile* ProjectBuildTarget* GetFile(int)' <=
/// use, add ====> 'ProjectFile * cbProject::GetFile(int)' <==== use
///-----------------------------------------------------------------------------
/// ** for svn < r7588 ** (release 10.05, svn7550, ..)
/// no official patch : 'projectbuildtarget_GetFiles.patch'
/// this script use one new method of patch :
/// use, add ====> 'wxArrayString ProjectFile::buildTargets' <==== use
/// add => 'int ProjectBuildTarget::GetFilesCount()' <=
/// add => 'ProjectFile* ProjectBuildTarget* GetFile(int)' <=
///-----------------------------------------------------------------------------
///-----------------------------------------------------------------------------
/// display all files projects with cibles
///-----------------------------------------------------------------------------
class DisplayAllFilesProject extends cbScriptPlugin {
/// members
// membres
VERSION = _T("0.4.0");
///-----------------------------------------------------------------------------
/// mandatory to init script plugin
///-----------------------------------------------------------------------------
constructor() {
/// constructor base class
cbScriptPlugin.constructor();
/// setup the plugin's info
info.name = _T("DisplayAllFilesProject");
info.title = _("Display files project");
info.version = VERSION;
info.license = _T("GPL");
}
///-----------------------------------------------------------------------------
/// to create context menu entries
///-----------------------------------------------------------------------------
function GetModuleMenu(who, data) {
local entries = ::wxArrayString();
if (who == ::mtProjectManager) {
entries.Add(_("Display files project"), 1);
}
return entries;
}
///-----------------------------------------------------------------------------
/// calback for context menu items clicking
///-----------------------------------------------------------------------------
function OnModuleMenuClicked(index) {
main();
}
///-----------------------------------------------------------------------------
///displays all files of each target on script console
///-----------------------------------------------------------------------------
function main() {
/// general
local Project = GetProjectManager().GetActiveProject();
local Ntargets = Project.GetBuildTargetsCount() ;
local Nf = Project.GetFilesCount();
//----------------------------------------------
/// file relative name
local name;
/// informations
local Mes = _T("Project : '") + Project.GetTitle() + _T("' : ") ;
Mes += Nf.tostring() + _T(" files, ") ;
Mes += Ntargets.tostring() + _T(" targets : ") ;
::print(Mes );
/// array targets
local tabtargets;
local nt;
local target;
local prjfile;
/// all files
for (local u =0 ; u < Nf; u++ ) {
///-- only >= r7588------ patch to 'Project' class -----------------------------
prjfile = Project.GetFile(u);
///-----------------------------------------------------------------------------
name = prjfile.relativeFilename
/// copy
///-------------------- patch to 'ProjectFile' class ---------------------------
tabtargets = prjfile.buildTargets;
///-----------------------------------------------------------------------------
nt = tabtargets.GetCount();
Mes = u.tostring() + _T("- '") + name + _T("'") ;
Mes += _T(" is linked to ") + nt.tostring() + _T(" target(s)")
::print(Mes);
Mes = _T("");
/// all file targets
for (local t=0; t < nt; t++) {
target = tabtargets.Item(t);
Mes += _T(" '")+ target + _T("',") ;
}
::print (Mes);
}
} /// end main()
} /// class end
///-----------------------------------------------------------------------------
/// this call actually registers the script plugin with Code::Blocks
///-----------------------------------------------------------------------------
RegisterPlugin(DisplayAllFilesProject());
///-----------------------------------------------------------------------------
--- End code ---
no problem using the methods.
I check 'int ProjectBuildTarget::GetFilesCount()' and 'ProjectFile* ProjectBuildTarget* GetFile(int)'
with script plugin : 'listfilestargets.script' :
--- Code: ---/*******************************************************************************
* Name: listfilestargets.script
* Purpose: Script plugin in CODE::BLOCKS
* Author: LETARTARE (http://forums.codeblocks.org)
* Created: 2011-12-17
* Version 0.5.0
* Copyright: LETARTARE
* License: GPL
******************************************************************************/
/// ATTENTION
///-----------------------------------------------------------------------------
/// ** for svn r7639 ** (by 'jens')
///-----------------------------------------------------------------------------
/// ** for svn in r7588..r7639 **, 'GetFile(int)' was deleted !!!
/// patch 'reimplement_GetFile_index_20111212-1.patch' in r7639 (by 'jens')
/// this script use two new methods of patch :
/// add => 'wxArrayString ProjectFile::buildTargets' <=
/// use, add ====> 'int ProjectBuildTarget::GetFilesCount()' <====
/// use, add ====> 'ProjectFile* ProjectBuildTarget* GetFile(int)' <====
/// add => 'ProjectFile * cbProject::GetFile(int)' <=
///-----------------------------------------------------------------------------
/// ** for svn < r7588 ** (release 10.05, svn7550, ..)
/// no official patch : 'projectbuildtarget_GetFiles.patch'
/// this script use two new methods of patch :
/// add => 'wxArrayString ProjectFile::buildTargets' <===
/// use, add ====> 'int ProjectBuildTarget::GetFilesCount()' <==== use
/// use, add ====> 'ProjectFile* ProjectBuildTarget* GetFile(int)' <==== use
///-----------------------------------------------------------------------------
///-----------------------------------------------------------------------------
/// display all files targets
///-----------------------------------------------------------------------------
class DisplayAllFilesTargets extends cbScriptPlugin {
/// members
VERSION = _T("0.5.0");
///-----------------------------------------------------------------------------
/// mandatory to init script plugin
///-----------------------------------------------------------------------------
constructor() {
/// constructor base class
cbScriptPlugin.constructor();
/// setup the plugin's info
info.name = _T("DisplayAllFilesTargets");
info.title = _("Display files targets");
info.version = VERSION;
info.license = _T("GPL");
}
///-----------------------------------------------------------------------------
/// to create context menu entries
///-----------------------------------------------------------------------------
function GetModuleMenu(who, data) {
local entries = ::wxArrayString();
if (who == ::mtProjectManager) {
entries.Add(_("Display files targets only"), 1);
}
return entries;
}
///-----------------------------------------------------------------------------
/// calback for context menu items clicking
///-----------------------------------------------------------------------------
function OnModuleMenuClicked(index) {
main();
}
///-----------------------------------------------------------------------------
///displays all files of each target on script console
///-----------------------------------------------------------------------------
function main() {
/// general
local Project = GetProjectManager().GetActiveProject();
if (IsNull(Project)) {
ShowError( _("Currently no project is loaded/activated. Cannot continue.") );
return 0;
}
local Ntargets = Project.GetBuildTargetsCount() ;
if (Ntargets == 0) {
ShowError( _("No target in this project. Cannot continue.") );
return 0;
}
local Nfiles = Project.GetFilesCount() ;
if (Nfiles == 0) {
ShowError( _("No file in this project. Cannot continue.") );
return 0;
}
/// file relative name
local file;
local target;
local nfilestarget;
local i=0;
/// informations
local Mes = _T("Project : '") + Project.GetTitle() + _T("' : ") ;
Mes += Nfiles.tostring() + _T(" files, ") ;
Mes += Ntargets.tostring() + _T(" targets : ") ;
::print(Mes );
/// all project targets
for (local ti=0; ti < Ntargets ; ti++ ) {
target = Project.GetBuildTarget(ti) ;
Mes = _T("\nTarget ") + ti.tostring() + _T(" : '") ;
Mes += target.GetFullTitle() + _T("'") ;
::print(Mes);
///------------- patch to 'ProjectBuildTarget' class ---------------------------
nfilestarget = target.GetFilesCount();
///-----------------------------------------------------------------------------
if (nfilestarget == 0)
continue;
/// all files target
for (local nf =0 ; nf < nfilestarget ; nf++) {
///------------- patch to 'ProjectBuildTarget' class ---------------------------
file = target.GetFile(nf).relativeFilename;;
///-----------------------------------------------------------------------------
::print (_T(" ") + nf.tostring() + _T(" : '") + file + _T("'"));
i++;
}
}
::print(_T("\nTotal files associated to targets : ") + i.tostring());
} /// end main()
} /// class end
///-----------------------------------------------------------------------------
/// this call actually registers the script plugin with Code::Blocks
///-----------------------------------------------------------------------------
RegisterPlugin(DisplayAllFilesTargets());
///-----------------------------------------------------------------------------
--- End code ---
no problem using the methods.
As against the testing of a large project C::B (eg svn 7550) shows a display in the console, which blocks 2 to 3 seconds (at about 2 / 3) and then restarts !
This anomaly does not occur in r7550 and r6283 (adjusted with patch personnal).
I guess it comes from the refresh of the window ?
Perhaps he should open another topic ?
Navigation
[0] Message Index
[*] Previous page
Go to full version