Sha256: 3342264a524ab0b91fae443504ae0514a50f598675b43b6d2cb41ce3ea071920

Contents?: true

Size: 791 Bytes

Versions: 4

Compression:

Stored size: 791 Bytes

Contents

require 'ludy/tasks/common'

module Kernel
private
  # it simply output:
  #  #ifndef NDEBUG
  #  #include <iostream>
  #  #endif
  def debug_include
'#ifndef NDEBUG
#include <iostream>
#endif'
  end
  # example usage:
  #  void <% debug_hook 'C::f' do %>(){
  #    <% end %>
  #    std::cout << "hello" << std::endl;
  #  }
  # became:
  #  void C::f(){
  #    #ifndef NDEBUG
  #    std::cerr << "method C::f called, for " << this << " at c.cpp: 12\n"
  #    #endif
  #    std::cout << "hello" << std::endl;
  #  }
  def debug_hook name, &block
    Ludy::erbout name, block.binding
    block.call
    Ludy::erbout "
#ifndef NDEBUG
std::clog << \"method #{name} called, for \" << this << \" at #{@file}: #{eval '__LINE__', block.binding}\\n\";
#endif
", block.binding
  end
end # of Kernel

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
godfat-ludy-0.1.13 lib/ludy/tasks/preprocess_cpp/debug_hook.rb
ludy-0.1.15 lib/ludy/tasks/preprocess_cpp/debug_hook.rb
ludy-0.1.11 lib/ludy/tasks/preprocess_cpp/debug_hook.rb
ludy-0.1.13 lib/ludy/tasks/preprocess_cpp/debug_hook.rb