Exemplo n.º 1
0
  public SixModelObject get_attribute_boxed(
      ThreadContext tc, SixModelObject class_handle, String name, long hint) {
    SixModelObject member = memberCache.get(name);
    if (member != null) return member;

    CStructREPRData data = (CStructREPRData) class_handle.st.REPRData;
    AttrInfo info = data.fieldTypes.get(name);

    Object o = storage.readField(name);
    if (info.inlined == 0) {
      if (info.argType == ArgType.CSTRUCT) {
        Class<?> structClass = ((CStructREPRData) info.type.st.REPRData).structureClass;
        o = (Object) Structure.newInstance(structClass, ((Pointer) o));
      } else if (info.argType == ArgType.CPPSTRUCT) {
        Class<?> structClass = ((CPPStructREPRData) info.type.st.REPRData).structureClass;
        o = (Object) Structure.newInstance(structClass, ((Pointer) o));
      } else if (info.argType == ArgType.CUNION) {
        Class<?> structClass = ((CUnionREPRData) info.type.st.REPRData).structureClass;
        o = (Object) Union.newInstance(structClass, ((Pointer) o));
      }
    }

    member = NativeCallOps.toNQPType(tc, info.argType, info.type, o);
    memberCache.put(name, member);
    return member;
  }
Exemplo n.º 2
0
 public void bind_attribute_boxed(
     ThreadContext tc, SixModelObject class_handle, String name, long hint, SixModelObject value) {
   CStructREPRData data = (CStructREPRData) class_handle.st.REPRData;
   AttrInfo info = data.fieldTypes.get(name);
   /* XXX: This'll break if we try to set a callback member. OTOH, it's
    * broken on Parrot too, so it's not a NativeCall regression as
    * such... */
   ArgType type = info.argType;
   Object o = NativeCallOps.toJNAType(tc, value, type, null);
   if (info.inlined == 0) {
     if (type == ArgType.CSTRUCT || type == ArgType.CPPSTRUCT) {
       type = ArgType.CPOINTER;
       o = (Object) ((Structure) o).getPointer();
     } else if (type == ArgType.CUNION) {
       type = ArgType.CPOINTER;
       o = (Object) ((Union) o).getPointer();
     }
   }
   storage.writeField(name, o);
   memberCache.put(name, value);
 }
Exemplo n.º 3
0
  public void refresh(ThreadContext tc) {
    CStructREPRData repr_data = (CStructREPRData) st.REPRData;

    // Recursively refresh our members.
    for (Entry<String, SixModelObject> entry : memberCache.entrySet()) {
      ArgType argType = repr_data.fieldTypes.get(entry.getKey()).argType;
      SixModelObject child = entry.getValue();
      if (argType == ArgType.CARRAY
          || argType == ArgType.CSTRUCT
          || argType == ArgType.CPPSTRUCT
          || argType == ArgType.CUNION) {
        NativeCallOps.refresh(child, tc);
      }
    }

    /* This is the take a hammer to it approach. Just dump the entire
     * cache and rebuild everything on next read. Future versions should
     * compare the pointer in C memory and the one in the object in the
     * loop above and only dump the entries where the two are different.
     */
    memberCache.clear();
  }