68 Commits

Author SHA1 Message Date
Allan Odgaard
437f640e74 Implement move assignment and constructor for oak::basic_tree_t 2016-06-20 18:19:13 +02:00
Allan Odgaard
8e8a647e25 Add algorithm to erase descendent keys form a std::map
This can be used when the key is name spaced, e.g. `/foo/bar` or `foo.bar`. Here we can erase everything under foo by using `/foo/` or `foo.` respectively.
2016-06-02 21:07:43 +02:00
Ronald Wampler
00a20aefb6 Revert "Disable unused-local-typedef warning for sparsehash"
This reverts commit 2c6ad9b391.

Upstream released a new version, which resolved the warnings this commit meant to suppress.
2015-10-22 16:27:40 +07:00
Ronald Wampler
2c6ad9b391 Disable unused-local-typedef warning for sparsehash
Also, disable unknown-pragmas warning for older version of clang.
2015-08-11 21:01:07 +02:00
Ronald Wampler
f3d1abaeca Introduce tls_ptr_t
This is a lightweight wrapper around the pthread methods to access thread local memory.
2015-08-11 21:01:07 +02:00
Allan Odgaard
457969788e Use std::tuple for the OS version
This makes compatibility checks simpler, since we can use a single comparison operator.
2015-06-23 22:46:58 +02:00
Joachim Mårtensson
70893f4583 Use dense_hash_map for style cache 2015-05-09 21:24:38 +02:00
Allan Odgaard
0f4397769d Include the cstdlib header
This is to ensure we get the integer prototype for std::abs
2015-05-06 21:19:07 +02:00
Ronald Wampler
4aff7098a5 Use std::abs instead of abs()
This suppresses a couple of warnings with the latest version of clang shipped with Xcode 6.3.
2015-04-30 15:15:56 +02:00
Allan Odgaard
29a576ffbe Don’t go via helper for pthread_setname_np
This was previously done because the function wasn’t available until 10.7, but since that is (now) our deployment target, there is no need to wrap the call.
2014-12-25 09:36:01 +01:00
Allan Odgaard
0bdefafac3 Remove dependency graph support to only framework using this API 2014-12-25 09:33:56 +01:00
Allan Odgaard
aeb9ab7d00 Move server.h to the only framework left using this legacy API 2014-12-25 09:33:13 +01:00
Allan Odgaard
0c99cb0699 Remove unused helper function 2014-12-25 09:32:23 +01:00
Allan Odgaard
3a86535022 Move boost crc include to PCH
Also use unsigned integer for the checksum.
2014-10-18 12:36:23 +02:00
Allan Odgaard
7cb2330aae Log error if curl_easy_init() or accept() fails 2014-09-30 14:15:11 +02:00
Allan Odgaard
ec81a045af Force a layout before opening window (from tests)
This appears to be a requirement (to do it manually). Running 10.9.4.
2014-09-17 10:35:25 +02:00
Allan Odgaard
57e43f27e3 Return 0 if Gestalt() fails 2014-08-21 16:06:33 +02:00
Allan Odgaard
c272afaff2 Cleanup/harmonize whitespace
Leading indent should consist only of tabs, beyond that, only spaces should be used.
2014-04-25 16:55:31 +07:00
Allan Odgaard
39b94e6ac3 Harmonize whitespace and add trailing newline 2014-04-14 14:26:52 +07:00
Allan Odgaard
5b47dca1e6 Add ‘sysexits.h’ as a precompiled header 2014-04-14 08:55:06 +07:00
Allan Odgaard
10d94644f7 Switch oak::server_t implementation from pthread → libdispatch
This makes the abstraction redundant and it should be removed. I am doing that as a multi-step process, since the previous implementation was blocking tests from being updated to the new (dispatch queue based) test system.
2014-04-08 15:43:20 +07:00
Allan Odgaard
69c83e56df The ‘const’ keyword should be to the right of its type
The standard doesn’t care which side the keyword is placed on, but placing it on the right makes it easier to read types.

E.g. reading “int const* const” from right to left we get “const pointer to const integer”.
2014-03-31 08:27:19 +07:00
Allan Odgaard
2c20ab23b0 Ask for maximum queue length for pending socket connections
This is mainly because the SOMAXCONN constant looks better (in the source) than some arbitrarily chosen number. The constant is presently defined as 128 so it doesn’t seem wasteful, and presumably the queue will only take up space if we are not actually responding to socket connections.
2014-03-23 22:47:16 +07:00
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
1c308c810d Use map::emplace instead of inserting std::pair (C++11) 2013-09-05 20:59:11 +02:00
Allan Odgaard
02e64d17e6 Remove unused operation queue type 2013-09-03 12:27:20 +02:00
Allan Odgaard
e4e80a946c Use std::make_shared 2013-09-03 12:27:20 +02:00
Allan Odgaard
374f8a2248 Make oak::callbacks_t somewhat thread safe
If we only add, remove, and signal callbacks, the data type is now thread safe. This is mainly for the purpose of the concurrent tests.
2013-08-24 01:19:29 +02:00
Allan Odgaard
7a12fd1c41 Don’t define global macros that are only used in QuickLook target 2013-08-16 22:40:07 +02:00
Allan Odgaard
b25f716f86 Remove rforeach macro 2013-08-12 19:32:23 +02:00
Allan Odgaard
12067e806a Don’t keep mutex locked when calling client code
The mutex was locked to ensure that the client object did not go away, but the client’s code may terminate the program which destroys the server_t instance and thereby the mutex itself, which would previously cause an assertion to trigger, since the mutex was locked during destruction.

In practice there is no issue with the mutex not being locked while accessing the client object, as “unregister_client” and “master_run” are both called from the main thread, except for tests, but here we do not unregister client objects before their requests have been handled.
2013-08-12 19:32:23 +02:00
Allan Odgaard
2ad42430c4 Make client API for oak::server_t thread safe 2013-08-05 11:17:04 +02:00
Allan Odgaard
c3a6294806 Use std::function instead of templated argument 2013-08-03 17:22:01 +02:00
Allan Odgaard
84ef9bb768 Use std::transform instead of custom code 2013-08-03 13:22:03 +02:00
Allan Odgaard
84dc2dd871 Allow a target to use both new and old test system
Presently the new test system cannot be used for (interactive) GUI tests, so we keep the old one until we have that feature in the new.
2013-08-01 19:01:24 +02:00
Jacob Bandes-Storch
17e822896e Add Quick Look generator
Closes #1062
2013-07-30 23:11:49 +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
d5d01542f7 Support copying test::jail_t 2013-07-25 13:54:25 +02:00
Allan Odgaard
eb1acfe70f Remove box_layout.h header (unused) 2013-06-28 08:42:06 +02:00
Allan Odgaard
58cfa20a1b Add operator<< for std::map
This is to allow chaining inserts and to avoid temporary variables when inserting maps returned from functions.
2013-05-12 11:09:16 +07:00
Allan Odgaard
b489687403 Disable AuthorizationExecuteWithPrivileges deprecation warning
The “proper” replacement for this API is to use the ServiceManagement framework’s SMJobBless() to bless our helper tool. In two of the three use-cases our helper tool is however regular shell commands, so it seems redundant to wrap these shell tools as helper tools we can install as launchd jobs.
2013-05-06 14:51:31 +07:00
Allan Odgaard
398e55cdbe Add helper functions to get OS version
We need this in a few places and while calling Gestalt() isn’t that much code, that function is deprecated in 10.8 and the alternative is a lot more code, so we don’t want to repeat that once we update the code.
2013-03-17 15:44:06 +01:00
Allan Odgaard
d18b30f280 Remove oak::lock_t and oak::mutex_t 2013-03-13 12:37:21 +01:00
Allan Odgaard
24f6f3bd2c Use posix_spawn instead of fork/exec
Using Apple’s POSIX_SPAWN_CLOEXEC_DEFAULT appears to be the only safe way to spawn a child process in a multi-threaded program.
2013-03-10 16:07:11 +01:00
Allan Odgaard
13edc6d131 Use O_CLOEXEC when opening files
This avoids leaking file descriptors into child processes, which would otherwise happen if another thread forks while the file descriptor is open.
2013-03-10 16:07:10 +01:00
Allan Odgaard
090a6ac698 Increase queue size for test (web) server
With concurrent tests and sequential handling of requests, the queue size is likely to grow to “number of concurrent tests”.
2013-03-10 16:07:10 +01:00
Allan Odgaard
eb893105e4 Disallow copying test::jail_t
Since we delete the jailed directory in the destructor we can’t support a deep copy of this type. Since we don’t need it, and it’s just a type used in tests, I opted for simply disabling this (to get a compiler error, should it be attempted) rather than introduce the necessary code to allow shallow copies.
2013-02-25 15:26:41 +01:00
Allan Odgaard
4712515e8b Allow passing a window to OakSetupApplicationWithView
Should rename the function to reflect this new flexibility.
2013-02-04 19:38:31 +01:00
Allan Odgaard
5e291d8a22 Improve QuickLook support
Preview can now be initiated with multiple items and while the preview panel is showing, one can use arrow up/down to switch to other items (in the file browser).
2013-01-12 13:09:19 +01:00
Allan Odgaard
701c9a0541 Use ‘std’ namespace prefix when calling search()
This is to avoid a clash with other things named ‘search’.
2012-12-28 02:47:19 +01:00