Commit Graph

61 Commits

Author SHA1 Message Date
Allan Odgaard
c2397484b8 Use C++11 for loop
Majority of the edits done using the following ruby script:

    def update_loops(src)
      dst, cnt = '', 0

      block_indent, variable = nil, nil
      src.each_line do |line|
        if block_indent
          if line =~ /^#{block_indent}([{}\t])|^\t*$/
            block_indent = nil if $1 == '}'
            line = line.gsub(%r{ ([^a-z>]) \(\*#{variable}\) | \*#{variable}\b | \b#{variable}(->) }x) do
              $1.to_s + variable + ($2 == "->" ? "." : "")
            end
          else
            block_indent = nil
          end
        elsif line =~ /^(\t*)c?iterate\((\w+), (?!diacritics::make_range)(.*\))$/
          block_indent, variable = $1, $2
          line = "#$1for(auto const& #$2 : #$3\n"
          cnt += 1
        end
        dst << line
      end
      return dst, cnt
    end

    paths.each do |path|
      src = IO.read(path)

      cnt = 1
      while cnt != 0
        src, cnt = update_loops(src)
        STDERR << "#{path}: #{cnt}\n"
      end

      File.open(path, "w") { |io| io << src }
    end
2014-03-03 10:34:13 +07:00
Allan Odgaard
4609378cdc Introduce bundles::kItemTypeMost constant 2014-03-02 13:13:04 +07:00
Allan Odgaard
1f74cef1bd Avoid storing ‘false’ (as value) in bundle items
Since we treat a missing key as having the value ‘false’ there is no need to write out keys set to false. This was partly motivated by improving cached data since here we store non-strings as binary property lists, and boolean values are non-strings (not that we have that many keys set to false, but it would e.g. happen if user disable an item and later enable it).
2014-02-19 20:48:13 +07:00
Allan Odgaard
ed852ae5b2 Empty delta bundle items no longer result in a file on disk
For example if the user makes a change and later reverts it (in the bundle editor) there should no longer be a local (delta) item saved. Though the containing delta bundle remains (but ideally that should be removed as well).
2014-02-14 22:37:55 +07:00
Allan Odgaard
1092afde25 Deleted bundle items were returned when asking for disabled items
This would cause deleted (delta) items to show up in the bundle editor (as it queries the bundle manager for disabled items and would thus also get the deleted ones).
2014-01-31 19:06:38 +07:00
Allan Odgaard
1c308c810d Use map::emplace instead of inserting std::pair (C++11) 2013-09-05 20:59:11 +02:00
Allan Odgaard
e4e80a946c Use std::make_shared 2013-09-03 12:27:20 +02:00
Allan Odgaard
bbe14f0a0b Add mutex for bundles::item_t::plist
This is (once again) only for the concurrent tests, although we probably do want to use the bundles API from more threads in the future.
2013-08-24 01:19:29 +02:00
Allan Odgaard
bf1e92b865 Do not use global constructors for fixtures 2013-08-16 22:40:08 +02:00
Allan Odgaard
67c3a92855 Add some const keywords 2013-08-16 22:40:08 +02:00
Allan Odgaard
0bcae7957e Minor speed improvement in creating bundle index 2013-08-16 22:40:08 +02:00
Allan Odgaard
9eeda712df Limit code duplication 2013-08-14 10:41:30 +02:00
Jacob Bandes-Storch
5bfd29b604 Move load_bundles to bundles framework 2013-07-28 21:57:51 +02:00
Jacob Bandes-Storch
f2df57df60 Rename “index.{cc,h}” to the more appropriate “item.{cc,h}” 2013-07-28 21:57:31 +02:00
Jacob Bandes-Storch
97199ad0a6 Move some bundles code from index.h to query.h 2013-07-28 21:57:31 +02:00
Allan Odgaard
2e488b4ee7 Update testing system for bundles framework 2013-07-26 13:53:57 +02:00
Allan Odgaard
ce395fa46a Make bundle item queries thread safe
Note though that mutating the bundle item index is not allowed if other threads are querying it.
2013-07-26 13:53:57 +02:00
Allan Odgaard
ffc622c63d Deleting a bundle would only delete the contained info.plist 2013-06-29 12:42:34 +02:00
Allan Odgaard
598e80f06b Resolve path for a bundle item after it has been created
We may save to a symlinked path but generally always work with resolved paths (for cache lookups, fs-events, etc.).
2013-06-29 12:42:34 +02:00
Allan Odgaard
59a67be348 Handle creating a new bundle with name of existing bundle
Previously we would ensure that /path/to/info.plist inside the bundle was unique when we should have ensured that the actual bundle name was unique.
2013-06-29 12:42:34 +02:00
Allan Odgaard
2df18d80b0 The bundle’s info.plist can now specify requiredCommands
This will apply to all items in the bundle so it’s questionable if it’s something we want to use, as it would not allow the user to run a “Help” command from the bundle without first setting up the requirements. OTOH setting requiredCommands for all but a few items in e.g. the Git bundle seems redundant — perhaps items should be able to eclipse keys from the bundle’s info.plist to effectively unset the requiredCommands for a select few items.
2013-05-26 15:40:23 +08:00
Allan Odgaard
0594b2c83e Fix issue with requirements that had no locations array
The variable provided was ignored meaning that it would only work correctly if the executable was found via PATH, and if it wasn’t found, the error message would display a bogus character as the variable that the user should set.
2013-05-26 15:34:54 +08:00
Allan Odgaard
77a6dcebfe Remove unused typedef 2013-05-12 11:09:17 +07:00
Allan Odgaard
8b3f05485d Change argument ordering for ‘scope_variables’
Generally we should always provide a base environment, since the scoped variables are format strings. The filtering scope selector is however optional, and we do not have one when executing commands outside an fi;e/editor context.
2013-05-12 11:09:17 +07:00
Allan Odgaard
f02a68893d Don’t pass base environment to bundle_variables 2013-05-12 11:09:16 +07:00
Allan Odgaard
0fd03842b7 Move bundle requirement checking to bundles framework
This also generalizes it to being applicable to all bundle items (not just commands).
2013-05-09 15:16:33 +07:00
Allan Odgaard
5fd188531a Change naming of functions for obtaining variables
These are now all prefixed with what they are obtaining variables for (scope, document, bundle, …) which makes it easier to analyze/refactor the code.

Also change document_t’s settings function to document_settings.
2013-05-09 15:16:32 +07:00
Allan Odgaard
258db64b8f Remove old bundle loading code 2013-03-25 13:22:54 +01:00
Allan Odgaard
1a4fd97208 Add missing include 2013-03-25 13:20:34 +01:00
Allan Odgaard
ca0a839247 Make helper data type local 2013-03-20 13:54:16 +01:00
Allan Odgaard
42cd2f93df Make fs::tree_t member data private 2013-03-20 11:30:41 +01:00
Allan Odgaard
21bf41b0c6 fixup! No longer support deleted items in bundle’s info.plist
We still need to cache the ‘deleted’ key since delta items use this to indicate keys deleted in the local version.
2013-03-18 14:34:08 +01:00
Allan Odgaard
916725b0d2 Use constant for version of property cache format 2013-03-18 14:34:08 +01:00
Allan Odgaard
b96a4975e6 Use array for cached settings names
We previously used a dictionary so that initializing a bundle item object wouldn’t need to know the difference between a full property list and a cached subset. Technically though the previous code had an implicit assertion on the bundle item not being able to rely on the settings values being useful, which is now gone.

The main advantage though is a smaller and more correct cache format.
2013-03-18 14:34:07 +01:00
Allan Odgaard
12e5693361 Delete cached bundle items when changed on disk
Effectively it doesn’t change much as cached items are fetched with a file date, but in theory it should now be possible to omit that date (if we can trust that fs-events has always notified us about disk changes).
2013-03-18 14:34:07 +01:00
Allan Odgaard
f0fd87bf66 Only use cache file if at version 1
Since it’s not unlikely that a user will downgrade from a nightly build, we should be prepared to see cache files using a newer (incompatible) file format.
2013-03-17 16:03:11 +01:00
Allan Odgaard
062f78118a Don’t (re)scan when creating fs::node_t
Also make it optional to provide a map pointer (for collecting changes) when rescanning.
2013-03-17 16:03:11 +01:00
Allan Odgaard
04142cbf69 Bundle loading no longer done by static member function 2013-03-17 16:03:11 +01:00
Allan Odgaard
7d6763eee7 Avoid member data access when constructing bundles::item_t 2013-03-17 16:03:11 +01:00
Allan Odgaard
594bfcb29d No longer support deleted items in bundle’s info.plist
Recording that an item is deleted in the bundle’s info.plist is necessary for TextMate 1.x because it merges all installed bundles, so if the user has a local version, he will still see items from the default version, unless these are indicated to be deleted in the local version.

With 2.0 only delta bundles get merged with a less-local bundle, and when deleting a default item, a delta item is written with the ‘isDeleted’ key set to true.
2013-03-17 16:03:10 +01:00
Allan Odgaard
f888376e05 Move bundle loading to own file 2013-03-17 16:02:30 +01:00
Allan Odgaard
45dc49eb29 Retire compiler workaround
Previously we could get a compiler error when using std::map<std::string, std::string>() as a default argument.
2013-03-16 17:49:49 +01:00
Allan Odgaard
7de06dc9f4 Changing default bundle item settings could fail
The cache would not include changes to settings keys from delta bundles.
2013-02-25 15:28:37 +01:00
Allan Odgaard
b139ac5097 Change push_back → emplace_back (C++11)
This is mainly motivated by readability, so I only did a few select replacements.
2013-02-08 11:20:35 +01:00
Allan Odgaard
32fcb52c68 Workaround for clang linker warning
Using instances with static storage in Objective-C files result in the following warning (starting with clang 425.0.24):

ld: warning: direct access in […] to global weak symbol […] means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
2013-02-02 08:52:12 +01:00
Allan Odgaard
f477776ae0 Better console message for orphaned bundle items 2013-01-13 11:56:05 +01:00
Allan Odgaard
0f3861fec7 Retire custom begin/endof functions
We can now use std::begin/end although for containers we explicitly call the member functions.
2012-09-20 12:22:21 +02:00
Allan Odgaard
ebab500ba3 Use std::map/set instead of C arrays
These types come with a find() method and avoids having to use helper functions to get the begin/end of the array (for linear search).
2012-09-20 12:22:20 +02:00
Allan Odgaard
a3cedb5c58 Use std::function as callback type for setup_timer
There is a minor functional change in that the custom callback type uses event loop signaling that makes it safe to trigger the callback from a thread. This should however not be necessary for timers (which are all setup on the main thread).
2012-09-09 16:22:19 +02:00
Allan Odgaard
ffeb4ff991 Add simplistic parser for proxy item queries
This only support ‘||’ to allow chained queries, e.g.: ‘action.build || format.strong’.
2012-09-07 16:18:04 +02:00