aboutsummaryrefslogtreecommitdiff
path: root/bindings/ruby/init.c
AgeCommit message (Collapse)Author
2025-03-08ruby: fix "undefining the allocator of T_DATA" warningsJohannes Larsen
Ruby 3.2 introduced a warning when C-extensions use structs without redefining the allocation default allocation routine meant for objects. See https://bugs.ruby-lang.org/issues/18007 for details. In the Ruby bindings this happens at `Data_Wrap_Notmuch_Object` call sites, so the object types used there needed to update their allocation. This ruby code (given a database at the hardcoded path with messages matching `tag:tmp`) exercise all the ruby objects: require 'notmuch' Notmuch::Database.open File.expand_path("~/mail") do |db| db.get_directory("/tmp") db.query("tag:tmp").search_threads.each do |t| t.messages.each do |m| puts m.header("Subject") end end end Before these changes with ruby 3.2.5 and notmuch 0.38.3 it outputs: notmuch.rb:5: warning: undefining the allocator of T_DATA class Notmuch::Query notmuch.rb:5: warning: undefining the allocator of T_DATA class Notmuch::Threads notmuch.rb:5: warning: undefining the allocator of T_DATA class Notmuch::Thread notmuch.rb:6: warning: undefining the allocator of T_DATA class Notmuch::Messages notmuch.rb:6: warning: undefining the allocator of T_DATA class Notmuch::Message notmuch release 0.38.3 now available (the last line is the message I tagged with tmp), and after the changes: notmuch release 0.38.3 now available
2023-05-29ruby: db: reorganize initializerFelipe Contreras
In order to make it more extensible. No functional changes. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2023-04-12ruby: remove FileNames objectFelipe Contreras
Not used anymore now that we return an array of strings directly. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2023-04-02ruby: remove Tags objectFelipe Contreras
Not used anymore now that we return an array of strings directly. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-08-02ruby: split database close and destroyFelipe Contreras
Mirrors the C API: 7864350c (Split notmuch_database_close into two functions, 2012-04-25). Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-07-18ruby: create an actual wrapper structFelipe Contreras
Currently Ruby data points directly to a notmuch object (e.g. notmuch_database_t), since we don't need any extra data that is fine. However, in the next commit we will need extra data, therefore we create a new struct notmuch_rb_object_t wrapper which contains nothing but a pointer to the current pointer (e.g. notmuch_database_t). This struct is tied to the Ruby object, and is freed when the Ruby object is freed by the garbage collector. We do nothing with this wrapper, so no functionality should be changed. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-06-27ruby: add keyword arguments to db.queryFelipe Contreras
That way we don't need pass them to the query object ourselves. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-05-23ruby: use notmuch_exclude_t enumFelipe Contreras
It exists since 2013, let's allow it to be used in Ruby. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-05-17ruby: new notmuch_rb_object_destroy() helperFelipe Contreras
The struct used to store the types (rb_data_type_t) contains a "data" field where we can store whatever we want. I use that field to store a pointer to the corresponding destroy function. For example notmuch_rb_database_type contains a pointer to notmuch_database_destroy. I cast that pointer as a notmuch_status_t (func*)(void *) and call that function passing the internal object (e.g. notmuch_database_t). Using the rb_data_type_t data we can call the correct notmuch destroy function. Therefore this: ret = ((notmuch_status_t (*)(void *)) type->data) (nm_object); Is effectively the same as this: ret = notmuch_database_destroy (database); The advantage of doing it this way is that much less code is necesary since each rb_data_type_t has the corresponding destroy function stored in it. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-05-17ruby: add all data typesFelipe Contreras
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-05-17ruby: move towards more modern RTypedDataFelipe Contreras
Virtually the whole ruby core moved from RData to RTypeData, let's do so ourselves too. Basically the information typically passed through Data_Wrap_Struct is now stored in a struct rb_data_type_t (mark and free functions). This has the advantage that more information can be easily added, like the name of the type, a custom data ponter, and more. Data_Wrap_Struct is replaced with TypedData_Wrap_Struct, and the information is stored in a struct rb_data_type_t, rather than passed as arguments. Check_Type is replaced with Check_TypedStruct, which is a wrapper for rb_check_typeddata (with casts). #define Check_TypedStruct(v, t) \ rb_check_typeddata(RBIMPL_CAST((VALUE)(v)), (t)) We can use rb_check_typeddata directly, just like we use rb_data_object_get directly. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2021-04-18ruby: fix ruby 3.1 warningsFelipe Contreras
init.c:214:5: warning: ‘rb_cData’ is deprecated: by: rb_cObject. Will be removed in 3.1. [-Wdeprecated-declarations] Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2016-06-05Use https instead of http where possibleDaniel Kahn Gillmor
Many of the external links found in the notmuch source can be resolved using https instead of http. This changeset addresses as many as i could find, without touching the e-mail corpus or expected outputs found in tests.
2016-05-19ruby: add bindings for `notmuch_database_get_all_tags`Ludovic LANGE
The Ruby bindings were missing a way to get all the tags of the database. Now you should be able to access this with the public instance method `all_tags` of your database object. Example of use: notmuchdb = Notmuch::Database.new path, { :create => false, :mode => Notmuch::MODE_READ_ONLY } my_tags = notmuchdb.all_tags my_tags.each { |tag| print tag } my_tags.destroy! Amended by db: improve error reporting, add test
2014-05-18ruby: Add wrapper for notmuch_query_count_threadsWael M. Nasreddine
2013-02-18ruby: Add bindings for notmuch_thread_get_messagesAustin Clements
2012-06-29ruby: extern linkage portability improvementTomi Ollila
Some C compilers are stricter when it comes to (tentative) definition of a variable -- in those compilers introducing variable without 'extern' keyword always allocates new 'storage' to the variable and linking all these modules fails due to duplicate symbols. This is reimplementation of Charlie Allom's patch: id:"1336481467-66356-1-git-send-email-charlie@mediasp.com", written originally by Ali Polatel. This version has more accurate commit message.
2012-05-08ruby: Add wrapper for notmuch_query_set_omit_excluded()Ali Polatel
2012-05-08ruby: Add wrapper for notmuch_query_add_tag_excludeAli Polatel
2012-05-08ruby: Add wrapper for notmuch_query_count_messagesAli Polatel
2011-10-04ruby: Really add wrappers for database_find_message*Ali Polatel
Commit 898613116db746aa0f915ae43da8aba28545203d only added wrapper functions but did not register them. Register the functions in module's initialization function.
2011-10-04ruby: be consistent with notmuch's coding styleAli Polatel
No functional change, just indentation
2011-09-24ruby: New exception Notmuch::UnbalancedAtomicErrorAli Polatel
This exception wraps NOTMUCH_STATUS_UNBALANCED_ATOMIC which was added with the commit e59cc0031fbf84f49e32dedb9927f427d2c49309.
2011-09-24ruby: Wrap notmuch_database_{begin,end}_atomicAli Polatel
Adding ruby wrappers for functions: - notmuch_database_begin_atomic() - notmuch_database_end_atomic() added by 957f1ba3fc1d737887029ff1787fc6bea94de00b New functions: Notmuch::Database.begin_atomic() Notmuch::Database.end_atomic()
2011-09-24ruby: Rename destroy to destroy!Ali Polatel
According to the common Ruby function naming convention, potentially dangerous functions or functions which operate on the object itself are suffixed with an exclamation mark. Both of these are true for object destroying functions. The following modules are affected: - Notmuch::Directory - Notmuch::FileNames - Notmuch::Query - Notmuch::Threads - Notmuch::Thread - Notmuch::Messages - Notmuch::Message - Notmuch::Tags
2011-07-29ruby: Fix typo in documentationAli Polatel
It's Notmuch::FileNames not Notmuch::Filenames
2011-07-29ruby: Add markers to method definitions to help rdocAli Polatel
rdoc is dumb and needs markers in method definitions so that she can find which source file the method is defined in
2011-07-29ruby: Document remaining undocumented constantsAli Polatel
2011-07-29ruby: Document constants and exceptions right before definitionAli Polatel
2011-07-29ruby: Add list of classes to main documentationAli Polatel
2011-01-25ruby: Add wrapper for message_get_filenamesAli Polatel
2011-01-25ruby: Add wrappers for maildir sync. interfaceAli Polatel
New wrappers: notmuch_message_maildir_flags_to_tags(): MESSAGE.maildir_flags_to_tags notmuch_message_tags_to_maildir_flags(): MESSAGE.tags_to_maildir_flags
2011-01-25ruby: Add wrappers for query_get_s{ort,tring}Ali Polatel
New wrappers: notmuch_query_get_sort(): QUERY.sort notmuch_query_get_query_string(): QUERY.to_s
2010-06-06ruby: Don't barf if an object is destroyed more than onceAli Polatel
Raise RuntimeError instead. Also revise Notmuch::Database a bit. Add Notmuch::Database.open singleton method.
2010-06-06ruby: Kill garbage collection related cruft.Ali Polatel
Let the user destroy objects that she wants explicitly. It's not possible to specify the order objects are garbage collected. See id:86y6f8v838.fsf@harikalardiyari.ev on ruby-talk for more information.
2010-06-06Initial ruby bindingsAli Polatel