org.gnome.gobject.Parameter Maven / Gradle / Ivy
// Java-GI - Java language bindings for GObject-Introspection-based libraries
// Copyright (C) 2022-2024 Jan-Willem Harmannij
//
// SPDX-License-Identifier: LGPL-2.1-or-later
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library 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
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, see .
//
// This file has been generated with Java-GI.
// Do not edit this file directly!
// Visit for more information.
//
package org.gnome.gobject;
import io.github.jwharm.javagi.base.ManagedInstance;
import io.github.jwharm.javagi.interop.Interop;
import java.lang.Deprecated;
import java.lang.String;
import java.lang.foreign.Arena;
import java.lang.foreign.MemoryLayout;
import java.lang.foreign.MemorySegment;
import java.lang.foreign.ValueLayout;
import javax.annotation.processing.Generated;
/**
* The GParameter struct is an auxiliary structure used
* to hand parameter name/value pairs to g_object_newv().
*/
@Generated("io.github.jwharm.JavaGI")
@Deprecated
public class Parameter extends ManagedInstance {
static {
GObjects.javagi$ensureInitialized();
}
/**
* Create a Parameter proxy instance for the provided memory address.
* @param address the memory address of the native object
*/
public Parameter(MemorySegment address) {
super(Interop.reinterpret(address, getMemoryLayout().byteSize()));
}
/**
* The memory layout of the native struct.
* @return the memory layout
*/
public static MemoryLayout getMemoryLayout() {
return MemoryLayout.structLayout(
ValueLayout.ADDRESS.withName("name"),
Value.getMemoryLayout().withName("value")
).withName("GParameter");
}
/**
* Allocate a new Parameter.
*
* @param arena to control the memory allocation scope
* @return a new, uninitialized {@link Parameter}
*/
public static Parameter allocate(Arena arena) {
MemorySegment segment = arena.allocate(getMemoryLayout());
return new Parameter(segment);
}
/**
* Allocate a new Parameter with the fields set to the provided values.
*
* @param arena to control the memory allocation scope
* @param name value for the field {@code name}
* @param value value for the field {@code value}
* @return a new {@link Parameter} with the fields set to the provided values
*/
public static Parameter allocate(Arena arena, String name, Value value) {
Parameter _instance = allocate(arena);
_instance.writeName(arena, name);
_instance.writeValue(value);
return _instance;
}
/**
* Read the value of the field {@code name}.
*
* @return The value of the field {@code name}
*/
public String readName() {
Arena _arena = Arena.ofAuto();
var _result = (MemorySegment) getMemoryLayout()
.varHandle(MemoryLayout.PathElement.groupElement("name")).get(handle());
return Interop.getStringFrom(_result, false);
}
/**
* Write a value in the field {@code name}.
*
* @param name The new value for the field {@code name}
*/
public void writeName(Arena _arena, String name) {
getMemoryLayout().varHandle(MemoryLayout.PathElement.groupElement("name"))
.set(handle(), (name == null ? MemorySegment.NULL : Interop.allocateNativeString(name, _arena)));
}
/**
* Read the value of the field {@code value}.
*
* @return The value of the field {@code value}
*/
public Value readValue() {
var _result = (MemorySegment) getMemoryLayout()
.varHandle(MemoryLayout.PathElement.groupElement("value")).get(handle());
return MemorySegment.NULL.equals(_result) ? null : new Value(_result);
}
/**
* Write a value in the field {@code value}.
*
* @param value The new value for the field {@code value}
*/
public void writeValue(Value value) {
getMemoryLayout().varHandle(MemoryLayout.PathElement.groupElement("value"))
.set(handle(), (value == null ? MemorySegment.NULL : value.handle()));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy