Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Helper: Add method to help defining instructions to link a instance u…

…p with a delegate.

Signed-off-by: Shin Yee <shinyee@speedgocomputing.com>
  • Loading branch information...
commit 0bd28efce60cc7ad12b1a56daef62b95b80a63f1 1 parent ac837c4
@xman authored
Showing with 51 additions and 0 deletions.
  1. +51 −0 lib/helpers/struct.rb
View
51 lib/helpers/struct.rb
@@ -0,0 +1,51 @@
+#
+# Copyright (c) 2011 Chung Shin Yee
+#
+# shinyee@speedgocomputing.com
+# http://www.speedgocomputing.com
+# http://github.com/xman/sgc-ruby-cuda
+# http://rubyforge.org/projects/rubycuda
+#
+# This file is part of SGC-Ruby-CUDA.
+#
+# SGC-Ruby-CUDA is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# SGC-Ruby-CUDA is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with SGC-Ruby-CUDA. If not, see <http://www.gnu.org/licenses/>.
+#
+
+module SGC
+module Helper
+
+module Struct
+
+ # @private
+ module Pvt
+
+ def self.define_delegated_struct_methods(klassA, klassD)
+ klassA.class_eval %{
+ def initialize(*args)
+ @source = #{klassD.name}.new(*args)
+ super(@source)
+ end
+
+ def to_api
+ @source
+ end
+ }
+ end
+
+ end
+
+end
+
+end # module
+end # module
Please sign in to comment.
Something went wrong with that request. Please try again.