rucy 0.1.8 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d6389e875eb101e6a833bf7fd8e5f3ef7579f381
4
- data.tar.gz: 7ff8ff8ee865b36934f2ebdcb67641ed4bf5bdfc
3
+ metadata.gz: 646a114233903a170a9c11e5f4af5f5b8f9c1d1d
4
+ data.tar.gz: 533042ab4b6c59c239e5f7a2497c76370c76fdd0
5
5
  SHA512:
6
- metadata.gz: 292fb66119c7e65044608dfd84474a561768f41561d7d29ea4eaa4d08fb542039b207f26f19a271462422fb3a6956d293cfedc690b2b7f1e43f92d7316a72c11
7
- data.tar.gz: 891da47387483201e047d68ffb53dcdf73e2f06658744c82f70154e66ed1a2eefdeee90f659545723c767a0e668cf6587e15e6a7d5a6e9540558d5e7c200b6be
6
+ metadata.gz: 1f739aa545afbde9cb4bc5bcc67158f381d098e4de0dbb61dfd9e0d2598363e8965de6617046c6687150c79f8b87eacdb5b76051f5993f3af28e612dcbf72ce2
7
+ data.tar.gz: eaf1449f0f84d087b9cc722737ac2534b9e2083c3b0711132be58f55d895079e6dd9a6f5bb703f5c216b55c774619f82873ab837e698473afecf6cb9bf520555
@@ -41,7 +41,10 @@ class RubyBase : public ClassWrapper<T>
41
41
  virtual const char* name_overridable () const
42
42
  {
43
43
  RUCY_SYM(name_overridable);
44
- return this->value.call(name_overridable).c_str();
44
+ if (RUCY_IS_OVERRIDABLE())
45
+ return this->value.call(name_overridable).c_str();
46
+ else
47
+ return Super::name_overridable();
45
48
  }
46
49
 
47
50
  virtual const char* name_overridable_faster () const
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.8
1
+ 0.1.9
data/ext/rucy/class.cpp CHANGED
@@ -41,7 +41,10 @@ class RubyBase : public ClassWrapper<T>
41
41
  virtual const char* name_overridable () const
42
42
  {
43
43
  RUCY_SYM(name_overridable);
44
- return this->value.call(name_overridable).c_str();
44
+ if (RUCY_IS_OVERRIDABLE())
45
+ return this->value.call(name_overridable).c_str();
46
+ else
47
+ return Super::name_overridable();
45
48
  }
46
49
 
47
50
  virtual const char* name_overridable_faster () const
@@ -86,10 +86,10 @@
86
86
  value (native_class* obj, Value klass) \
87
87
  { \
88
88
  if (!obj) return nil(); \
89
- ClassWrapper<native_class>* p = dynamic_cast<ClassWrapper<native_class>*>(obj); \
90
- if (!p) return new_ref(klass, obj); \
91
- if (p->value.is_nil()) p->value = new_wrapper(klass, obj); \
92
- return p->value; \
89
+ Value* pval = (Value*) obj->rucy_value(); \
90
+ if (!pval) return new_ref(klass, obj); \
91
+ if (pval->is_nil()) *pval = new_wrapper(klass, obj); \
92
+ return *pval; \
93
93
  } \
94
94
  }
95
95
 
@@ -128,10 +128,9 @@
128
128
  RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(native_class)
129
129
 
130
130
 
131
- #define RUCY_OVERRIDE_BEGIN(wrapper_class) \
132
- typedef wrapper_class RucyWrapper; \
133
- typedef RucyWrapper Super; \
134
- enum { OVERRIDE_ID_FIRST = RucyWrapper::OVERRIDE_ID_LAST - 1,
131
+ #define RUCY_OVERRIDE_BEGIN(super_class) \
132
+ typedef super_class Super; \
133
+ enum { OVERRIDE_ID_FIRST = super_class::OVERRIDE_ID_LAST - 1,
135
134
 
136
135
  #define RUCY_OVERRIDE_END \
137
136
  OVERRIDE_ID_LAST };
@@ -139,6 +138,9 @@
139
138
  #define RUCY_OVERRIDE_ID(name) \
140
139
  OID_##name,
141
140
 
141
+ #define RUCY_IS_OVERRIDABLE() \
142
+ this->is_overridable()
143
+
142
144
  #define RUCY_IS_OVERRIDDEN(name) \
143
145
  this->is_overridden(name, OID_##name)
144
146
 
@@ -255,7 +257,7 @@
255
257
  while(0)
256
258
 
257
259
  #define RUCY_WRAPPER_CALL(native_class, obj, fun) \
258
- ((obj)->rucy_wrapped() ? (obj)->native_class::fun : (obj)->fun)
260
+ ((obj)->rucy_disable_override() ? (obj)->fun : (obj)->fun)
259
261
 
260
262
 
261
263
  namespace Rucy
@@ -287,7 +289,7 @@ namespace Rucy
287
289
  GlobalValue value;
288
290
 
289
291
  ClassWrapper ()
290
- : value(nil(), true)
292
+ : value(nil(), true), overridable(true)
291
293
  {
292
294
  }
293
295
 
@@ -318,11 +320,28 @@ namespace Rucy
318
320
  override_flags.reset();
319
321
  }
320
322
 
323
+ virtual bool is_overridable () const
324
+ {
325
+ if (!overridable)
326
+ {
327
+ overridable = true;
328
+ return false;
329
+ }
330
+
331
+ return true;
332
+ }
333
+
321
334
  virtual bool is_overridden (const Symbol& name, uint id) const
322
335
  {
323
336
  if (id <= OVERRIDE_ID_UNKNOWN)
324
337
  return false;
325
338
 
339
+ if (!overridable)
340
+ {
341
+ overridable = true;
342
+ return false;
343
+ }
344
+
326
345
  bool checked = false, overridden = false;
327
346
  get_override_flag(&checked, &overridden, id);
328
347
  if (checked) return overridden;
@@ -334,8 +353,14 @@ namespace Rucy
334
353
  return overridden;
335
354
  }
336
355
 
337
- virtual bool rucy_wrapped () const
356
+ virtual void* rucy_value () const
338
357
  {
358
+ return (void*) &value;
359
+ }
360
+
361
+ virtual bool rucy_disable_override () const
362
+ {
363
+ overridable = false;
339
364
  return true;
340
365
  }
341
366
 
@@ -366,11 +391,20 @@ namespace Rucy
366
391
 
367
392
  mutable boost::dynamic_bitset<> override_flags;
368
393
 
394
+ mutable bool overridable;
395
+
369
396
  bool check_overridden (const Symbol& name) const
370
397
  {
371
398
  RUCY_SYM(method);
372
399
  RUCY_SYM(owner);
373
- return value.call(method, name.value()).call(owner) != get_ruby_class<RucyWrapped>();
400
+ RUCY_SYM(instance_methods);
401
+ RUCY_SYM_Q(include);
402
+ RUCY_SYM(clear_override_flags);
403
+ return !value
404
+ .call(method, name.value())
405
+ .call(owner)
406
+ .call(instance_methods, false)
407
+ .call(include, clear_override_flags.value());
374
408
  }
375
409
 
376
410
  void get_override_flag (bool* checked, bool* overridden, uint id) const
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rucy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - snori
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-24 00:00:00.000000000 Z
11
+ date: 2014-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake